View Single Post
Old 10 November 2019, 13:54   #15
deimos
It's coming back!
 
deimos's Avatar
 
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
Quote:
Originally Posted by ross View Post
I am very curious to see your results with quaternions.
I've attached the latest executable and the log output it generates.

My main loop currently does this:

Code:
    for (;;) {
        // ... stuff

        GameControls_Tick();

        Quaternion q;
        QuaternionFromOrientation(&q, &gameControls.controlSurfaces);

        Quaternion r = ((Entity *) cyclone)->attitude;

        MultiplyQuaternions(&((Entity *) cyclone)->attitude, &r, &q);
        PrintQuaternion("a", &((Entity *) cyclone)->attitude);

        DrawScreen();
    }
The output is something like this:

Code:
a = (4000, 0000, 0000, 0000) [10000000]
a = (4000, 0000, 0000, 0000) [10000000]
a = (4000, FF9B, 0000, 0000) [100027D9]
a = (3FFD, FED2, 0000, 0000) [0FFFE44D]
a = (3FF4, FDA4, 0000, 0000) [0FFF91A0]
a = (3FE0, FC12, 0000, 0000) [0FFF7544]
...
The last column is the square of the length of the quaternion without the right shift that would normally be done after multiplying fixed point numbers.

Code:
LONG QuaternionLengthSquared(const Quaternion * q) {
    return ((LONG) q->value[A] * (LONG) q->value[A] +
            (LONG) q->value[B] * (LONG) q->value[B] +
            (LONG) q->value[C] * (LONG) q->value[C] +
            (LONG) q->value[D] * (LONG) q->value[D]);
}
You can see it drifts away from 1 (<<28).

Edit: Very slowly, 0x0FFF7544 = 0.999868, and if I run it for longer, I get 0x0FE88AC1 = 0.994273.

Last edited by deimos; 21 November 2021 at 11:31.
deimos is offline  
 
Page generated in 0.05837 seconds with 11 queries