2016년 11월 4일 금요일

AxisAngle to Quaternion



qx = ax * sin(angle/2)
qy = ay * sin(angle/2)
qz = az * sin(angle/2)
qw = cos(angle/2)

where:

the axis is normalised so: ax*ax + ay*ay + az*az = 1
the quaternion is also normalised so cos(angle/2)2 + ax*ax * sin(angle/2)2 + ay*ay * sin(angle/2)2+ az*az * sin(angle/2)2 = 1


// assumes axis is already normalised
public void set(AxisAngle4d a1) {
  double s = Math.sin(a1.angle/2);
  x = a1.x * s;
  y = a1.y * s;
  z = a1.z * s;
  w = Math.cos(a1.angle/2);
}


http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/

댓글 없음:

댓글 쓰기