I want to rotate a float3 -90 degrees. i.e from (0,1,0) to (1,0,0). I tried to multiply the float3 with quaternion.AngleAxis but that doens’t work. If anyone knows how to do this without manually calculating the matrices pls help…
New rotation = current rotation * rotation offset
New vector = new rotation * vector
how would I do it in code tho? like I said multiplying quaternion with float 3 doesnt work so…?
Thanks
1 Like
I suggest look into topics covering adding and subtracting rotations, using quaternions.
In Dots you of course need use math.mul, instead *
Order of multiplication is extremely important, when comes to deal with rotations.
4 Likes
Nvm, I just use matrix calculation.
For anyone wondering if you wanna rotate float3 to the z-axis just use this formula/code :
float3 vector
float3 rotatedVector = new float(vector.y, -vector.x, vector.z)
basically you just switch the y and x and multiply x with -1
You can multiply it by cos/sin of target angle. For example:
float angle = -90;
float x = 1;
float y = 0;
float z = 0;
float3 newVector = new float3(
x * math.sin(math.radians(angle)),
y * math.cos(math.radians(angle)),
z
);