I am rotating a Vector2 by 90 degrees using the following code:
export const V2Rotate = (v: Vector2, q: Quaternion) => {
var matrix = new Matrix();
q.toRotationMatrix(matrix);
var rotatedvect = Vector2.Transform(v, matrix);
return rotatedvect;
}
But it doesnt seem to give the correct values, I am rotating a point (-121,0) by 90 degrees using
var quaternion1 = Quaternion.FromEulerAngles(0, 90, 0);
but instead of (0,-121) I get some other values.
I have checked with other Quaternions in case the axis was wrong but those are incorrect as well.
var quaternion = Quaternion.FromEulerAngles(Angle, 0, 0);
var quaternion1 = Quaternion.FromEulerAngles(0, Angle, 0);
var quaternion2 = Quaternion.FromEulerAngles(0, 0, Angle);
my actual point is (-121,0) and I get these results for those 3 cases:
(-121,0)
(54,0)
(54,-108)
Is it rotating from center and not origin? during the transformation?
Coming from Unreal Engine, I checked there giving the same Euler angle of Yaw 90 degrees I have two completely different Quaternions in UE vs BabylonJS. For ref:
UE - X=0 Y=-0 Z=0.7 W=0.7
BabylonJS - X=0 Y= 0.85 Z= 0 W=0.52
Unreal Has Z-axis as UP vector whereas Babylon has Y-axis for UP vector, is there some way to get the same result as the UE Quaternion?