New answers tagged quaternion
1
I don't know about the rotation part but for the mapping input to rotation you can do the following:
(this doesn't go in code)
add 32768 to your input getting a value 0-65535
from here you can get your multiplier which is 90/65535 = 0.00137
then to get your rotation distance you can simply multiply your input by your multiplier
(this goes in code)
...
0
I managed to fix everything through a lot of experimenting.
It seems my problem came from my own misunderstanding of quaternions.
I was under the impression that they represented a change in angle, when actually they represent an orientation.
So my rotation matrix was always a bit strange because I was just pushing seemingly random values into it, ...
1
Something i forgot to include was the fact the camera was moving with the ships. When I made the Camera stationary it seamed to work perfectly, so i simply created another camera and kept it at Vector3(0,30,0) and used it to track the mouse instead.
Changing the code slightly to be:
public static Quaternion RotateToMouse(this Ship ship, Transform ...
3
The MD5 file format assumes unit quaternions, which are of norm one. The norm of some quaternion q is:
|q| = sqrt((x * x) + (y * y) + (z * z) + (w * w))
You can rearrange this equation in terms of w by squaring both sides and then subtracting the terms containing x, y and z to yield:
(w*w) = (|q|*|q|) - (x*x) - (y*y) - (z*z)
Since the quaternion is ...
Top 50 recent answers are included