Hi,

I was hoping for some clarification about quaternions & matrix multiplication. The example I’m testing, ‘orientation’, is in the 0071 examples in the 3d folder. It displays a 3d cube moving around and orienting towards it’s direction of travel.

There is a strange flipping/spinning effect on the cube as it makes a turn from the top left of screen downwards (if you run the example, it happens after 10 seconds or so). Is this gimbal lock, or something else? I thought quaternions solved this problem?

Is there a fix or another way to orient an object to it’s direction so this irregularity does not occur? eg other matrix multiplications. Any advice or tips would be greatly appreciated.

Here’s the function which rotates the object from the example…

```
void rotateToNormal(ofVec3f normal) {
normal.normalize();
float rotationAmount;
ofVec3f rotationAngle;
ofQuaternion rotation;
ofVec3f axis(0, 0, 1);
rotation.makeRotate(axis, normal);
rotation.getRotate(rotationAmount, rotationAngle);
ofRotate(rotationAmount, rotationAngle.x, rotationAngle.y, rotationAngle.z);
}
```

Thanks,

Trent