def euler2angle_axis(z=0, y=0, x=0): ''' Return angle, axis corresponding to these Euler angles Uses the z, then y, then x convention above Parameters ---------- z : scalar Rotation angle in radians around z-axis (performed first) y : scalar Rotation angle in radians around y-axis x : scalar Rotation angle in radians around x-axis (performed last) Returns ------- theta : scalar angle of rotation vector : array shape (3,) axis around which rotation occurs Examples -------- >>> theta, vec = euler2angle_axis(0, 1.5, 0) >>> print(theta) 1.5 >>> np.allclose(vec, [0, 1, 0]) True ''' # delayed import to avoid cyclic dependencies import nibabel.quaternions as nq return nq.quat2angle_axis(euler2quat(z, y, x))
def infTwist(xyz): pts = xyz.T ors = normr(pts[1:] - pts[:-1]) start2end_rope = eye(3) for (or1, or2) in zip(ors[:-1], ors[1:]): start2end_rope = dot(minRot(or2, or1), start2end_rope) assert almostEq(dot(start2end_rope, ors[0]), ors[-1]) end2start_min = minRot(ors[0], ors[-1]) twist_mat = dot(end2start_min, start2end_rope) ang, _ = quat2angle_axis(mat2quat(twist_mat)) return ang
def infTwist(xyz): pts = xyz.T ors = normr(pts[1:] - pts[:-1]) start2end_rope = eye(3) for (or1,or2) in zip(ors[:-1],ors[1:]): start2end_rope = dot(minRot(or2,or1),start2end_rope) assert almostEq(dot(start2end_rope,ors[0]),ors[-1]) end2start_min = minRot(ors[0],ors[-1]) twist_mat = dot(end2start_min,start2end_rope) ang,_ = quat2angle_axis(mat2quat(twist_mat)) return ang