本文整理汇总了Python中Quaternion.mult_s_q方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.mult_s_q方法的具体用法?Python Quaternion.mult_s_q怎么用?Python Quaternion.mult_s_q使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion.mult_s_q方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: F_DX
# 需要导入模块: import Quaternion [as 别名]
# 或者: from Quaternion import mult_s_q [as 别名]
def F_DX(t, y, a):
#print("F_DX:\n\ty=%s\n\tt=%s\n\ta=%s" % (y, t, a))
dy = [0.0 for i in range(len(y))]
force, torque = a[0](y, t)
I_cm = a[1](y, t)
mass = a[2](y, t)
# The (w x I_cm w) term originates in the Newton-Euler equations, and
# should correspond to torque-free precession.
q = y[6:10]
q_w = np.asarray([0, y[10], y[11], y[12]])
q_dot = Q.mult_s_q(0.5, Q.mult_q_q(q, q_w))
pt_q_vec = np.asmatrix(Q.mult_q_q(Q.inv_q(q), q_dot)[1:4]).T
pseudo_torque = 4 * np.cross(pt_q_vec.T, (I_cm * pt_q_vec).T).T
alpha = np.linalg.solve(I_cm,np.asmatrix(torque).T - pseudo_torque)
# This assertion only holds for systems with diagonal I_cm, which is not
# the general case
#assert(np.linalg.norm(pseudo_torque) < 1e-6)
#q_len = np.sqrt(y[6]**2 + y[7]**2 + y[8]**2 + y[9]**2)
#q = [yq / q_len for yq in y[6:10]]
dy[0] = y[3]
dy[1] = y[4]
dy[2] = y[5]
dy[3] = force[0] / mass
dy[4] = force[1] / mass
dy[5] = force[2] / mass
dy[6:10] = q_dot
#dy[6] = 0.5 * (-y[7]*y[10] - y[8]*y[11] - y[9]*y[12])
#dy[7] = 0.5 * ( y[6]*y[10] - y[9]*y[11] - y[8]*y[12])
#dy[8] = 0.5 * ( y[9]*y[10] + y[6]*y[11] - y[7]*y[12])
#dy[9] = 0.5 * (-y[8]*y[10] + y[7]*y[11] + y[6]*y[12])
dy[10] = alpha[0]
dy[11] = alpha[1]
dy[12] = alpha[2]
dy[13:] = [l(y,t) for l in a[3]]
#print("dy=%s" % dy)
return np.asarray(dy)