def __init__(O, pivot): O.sites = [matrix.col((2 / 3., 0, 1 / 3.)) + pivot] O.A = joint_lib.revolute_alignment(pivot=pivot, normal=matrix.col((1, 0, 0))) O.I = spatial_inertia_from_sites(sites=O.sites, alignment_T=O.A.T0b) O.wells = O.sites O.J = joint_lib.revolute(qE=matrix.col([math.pi / 6.])) O.qd = matrix.col([0])
def __init__(O, pivot): O.sites = [matrix.col((2/3.,0,1/3.))+pivot] O.A = joint_lib.revolute_alignment( pivot=pivot, normal=matrix.col((1,0,0))) O.I = spatial_inertia_from_sites(sites=O.sites, alignment_T=O.A.T0b) O.wells = O.sites O.J = joint_lib.revolute(qE=matrix.col([math.pi/6.])) O.qd = matrix.col([0])
def __init__(O, labels, sites, bonds, pivot, normal, mersenne_twister): O.labels = labels O.sites = sites O.bonds = bonds O.A = joint_lib.revolute_alignment(pivot=pivot, normal=normal) O.I = spatial_inertia_from_sites(sites=O.sites, alignment_T=O.A.T0b) # O.wells = shift_gently(sites=O.sites, mersenne_twister=mersenne_twister) # O.J = joint_lib.revolute(qE=matrix.col([0])) O.qd = O.J.qd_zero
def d_pot_d_q_via_finite_differences(O, eps=1.e-6): result = [] for B in O.bodies: fs = [] J_orig = B.J for signed_eps in [eps, -eps]: B.J = joint_lib.revolute(qE=matrix.col((J_orig.qE[0]+signed_eps,))) O.e_pot_and_f_ext_update() fs.append(O.e_pot) B.J = J_orig result.append(matrix.col(((fs[0]-fs[1])/(2*eps),))) O.energies_and_accelerations_update() return result
def d_pot_d_q_via_finite_differences(O, eps=1.e-6): result = [] for B in O.bodies: fs = [] J_orig = B.J for signed_eps in [eps, -eps]: B.J = joint_lib.revolute(qE=matrix.col((J_orig.qE[0] + signed_eps, ))) O.e_pot_and_f_ext_update() fs.append(O.e_pot) B.J = J_orig result.append(matrix.col(((fs[0] - fs[1]) / (2 * eps), ))) O.energies_and_accelerations_update() return result
def __init__(O, mersenne_twister, prev=None): if (prev is None): normal = matrix.col(mersenne_twister.random_double_point_on_sphere()) pivot = matrix.col(mersenne_twister.random_double_point_on_sphere()) * 0.6 else: normal = prev.A.normal pivot = prev.A.pivot + normal * 0.3 O.sites = [pivot + normal * (-0.8)] O.A = joint_lib.revolute_alignment(pivot=pivot, normal=normal) O.I = spatial_inertia_from_sites(sites=O.sites, alignment_T=O.A.T0b) # O.wells = create_wells(sites=O.sites, mersenne_twister=mersenne_twister) # O.J = joint_lib.revolute(qE=matrix.col([math.pi/8])) O.qd = matrix.col([math.pi/12])
def __init__(O, mersenne_twister): def random_vector(): return matrix.col(mersenne_twister.random_double(size=3)*2-1) def random_angle(): return (mersenne_twister.random_double()*2-1)*math.pi # O.sites = [random_vector()] for i_trial in xrange(100): # guard against unlikely singularity O.A = joint_lib.revolute_alignment( pivot=random_vector(), normal=random_vector().normalize()) if (abs(O.A.normal.cos_angle(O.sites[0] - O.A.pivot)) > 1.e-3): break else: raise RuntimeError O.I = spatial_inertia_from_sites(sites=O.sites, alignment_T=O.A.T0b) # O.wells = [random_vector()] # O.J = joint_lib.revolute(qE=matrix.col([random_angle()])) O.qd = matrix.col([random_angle()])
def __init__(O, mersenne_twister): def random_vector(): return matrix.col(mersenne_twister.random_double(size=3) * 2 - 1) def random_angle(): return (mersenne_twister.random_double() * 2 - 1) * math.pi # O.sites = [random_vector()] for i_trial in range(100): # guard against unlikely singularity O.A = joint_lib.revolute_alignment( pivot=random_vector(), normal=random_vector().normalize()) if (abs(O.A.normal.cos_angle(O.sites[0] - O.A.pivot)) > 1.e-3): break else: raise RuntimeError O.I = spatial_inertia_from_sites(sites=O.sites, alignment_T=O.A.T0b) # O.wells = [random_vector()] # O.J = joint_lib.revolute(qE=matrix.col([random_angle()])) O.qd = matrix.col([random_angle()])