本文整理匯總了Python中Quaternion.inv_q方法的典型用法代碼示例。如果您正苦於以下問題:Python Quaternion.inv_q方法的具體用法?Python Quaternion.inv_q怎麽用?Python Quaternion.inv_q使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Quaternion
的用法示例。
在下文中一共展示了Quaternion.inv_q方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: F_DX
# 需要導入模塊: import Quaternion [as 別名]
# 或者: from Quaternion import inv_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)