public Vec3 RotateAround(Vec3 axis, float angle) { // rotate into world space var quaternion = Quat.FromRotationAxis(axis, 0); quaternion = quaternion.Conjugate(); var worldSpaceVector = this.Transform(quaternion); // rotate back to vector space quaternion = Quat.FromRotationAxis(axis, angle); worldSpaceVector = worldSpaceVector.Transform(quaternion); return(worldSpaceVector); }
public Mat3 RotateAround(Vec3 axis, float angle) { // rotate into world space var quaternion = Quat.FromRotationAxis(axis, 0).Conjugate(); var worldSpaceMatrix = this.Multiply(FromQuaternion(quaternion)); // rotate back to matrix space quaternion = Quat.FromRotationAxis(axis, angle); var qMat = Mat3.FromQuaternion(quaternion); worldSpaceMatrix = worldSpaceMatrix.Multiply(qMat); return(worldSpaceMatrix); }
public Mat4 FromRotationAxis(Vec3 axis, float angle) { Quat quaternion = Quat.FromRotationAxis(axis, angle); return(Mat4.FromQuaternion(quaternion)); }