## Rotation Matrix of Wheels of btRaycastVehicle not special orthogonal

marsch84
Posts: 1
Joined: Sun Jun 06, 2021 2:37 pm

### Rotation Matrix of Wheels of btRaycastVehicle not special orthogonal

I implemented btRaycastVehicle into a driving game. It works quite fine, but I have a problem with the orientation of the vehicle's wheels. After implementing some work-arounds, I realized, that the determinant of the rotation matrix is -1. As far as I understand, that means the matrix is orthogonal, but not special orthogonal. As soon as I converted the matrix to a quaternion or a GL matrix for graphical representation, the result was a very messy behavior of the wheels.

This is a snippet of my code that shows how the wheels are initialized:

Code: Select all

``````int rightIndex = 0;
int upIndex = 2;
int forwardIndex = 1;
btVector3 wheelDirectionCS0(0, 0, -1);
btVector3 wheelAxleCS(1, 0, 0);

vehicle->setCoordinateSystem(rightIndex, upIndex, forwardIndex);
connectionpoint = btVector3(0.63, 0.87, 0.0);
``````
The code uses the btDefaultVehicleRaycaster. The final work-around I developed was to turn the sign of the "right axis" of the wheel like this. After this change the rotation matrix is special orthogonal and all the quaternions derived from it are leading to the expected behavior.

Code: Select all

``````part[i].wheel[j].worldtrans = vehicle->getWheelTransformWS(j);
part[i].wheel[j].worldtrans.getBasis()[0][0] *= -1.0f;
part[i].wheel[j].worldtrans.getBasis()[1][0] *= -1.0f;
part[i].wheel[j].worldtrans.getBasis()[2][0] *= -1.0f;
``````
I later saw, that there is a commit to the source file of btRaycastVehicle (link below), that seems to introduce the same operation of inverting the sign of the right axis. This change should also be present in my version of the library (3.06). So it looks like, that I am basically reverting that operation of changing the sign in my code.

https://github.com/bulletphysics/bullet ... 1abdb31d79

So my question is, whether there is something wrong in how I initialize the wheels or whether the commit linked above introduced some kind of bug.