Quaternion

math

get the value about the rotation

a // = angle to rotate A(x, y, z) // = axis to rotate around P(0, x, y, z) // = point to rotate

build the quaternion

R = [cos(a/2), sin(a/2)*A.x, sin(a/2)*A.y, sin(a/2)*A.z] R2 = [0, -P.x, -P.y, -P.z]

calculate the new point with the hamilton product

P2 = ham( ham( R, P), R2 ) function ham(q1, q2) { return [ q1[0] * q2[0] - q1[1] * q2[1] - q1[2] * q2[2] - q1[3] * q2[3], q1[0] * q2[1] + q1[1] * q2[0] - q1[2] * q2[3] + q1[3] * q2[2], q1[0] * q2[2] + q1[1] * q2[3] + q1[2] * q2[0] - q1[3] * q2[1], q1[0] * q2[3] - q1[1] * q2[2] + q1[2] * q2[1] + q1[3] * q2[0] ] }

Reference

Wikipedia en.wikipedia.org

History May 02, 2018