Without @orient:
v@N; // +Z axis of the copy v@up; // +Y axis of the copy
Not ambiguous @orient, thanks to Matt Estela!
matrix3 m = maketransform(@N,@up); @orient = quaternion(m);
Representing a quaternion from an angle and axis. The angle is specified in radians:
float angle = radians(90); vector axis = set(0, 1, 0); p@rot = quaternion(angle, axis);
Representing a quaternion from a 3×3 rotational matrix:
float angle = radians(90); vector axis = {0,1,0}; matrix3 m = ident(); rotate(m, angle, axis); @orient = quaternion(m);
PI eight digits
#include "math.h"; float e = M_E; //2.7182818 f@angle = PI; //3.1415926 f@angle = radians(180);
Quaternion to Euler rotations
thanks to DJ
vector qToE(vector4 q_value){ float q_0 = q_value.w ; float q_1 = q_value.x ; float q_2 = q_value.y ; float q_3 = q_value.z ; vector out = {0,0,0} ; out.x = degrees(atan2(2*(q_0*q_1+q_2*q_3), (1-2*(q_1*q_1+q_2*q_2)))) ; out.y = degrees(asin(2*(q_0*q_2-q_3*q_1))) ; out.z = degrees(atan2(2*(q_0*q_3+q_1*q_2), (1-2*(q_2*q_2+q_3*q_3)))) ; return out ; } v@ro = qToE(p@orient);