# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Integrating Bullet with a Z-axis-up SystemPosted: Thu Nov 08, 2012 11:01 am

Joined: Fri Oct 26, 2012 1:50 pm
Posts: 33
Hi All,

I am integrating Bullet into a multi-physics-engine simulator that uses a right angle coordinate system with +Z as the 'up-axis'. As I understand, for implementation purposes Bullet can be seen as using a right angle coordinate system with +Y as the 'up-axis'. This problem is demonstrated visually as follows:
Attachment:
File comment: contrasting the bullet and simulator coordinate systems

rhcs.png [ 3.84 KiB | Viewed 2015 times ]

I have found scattered information on this issue, and what appears to be an adhoc solution in the RayCastVehicle class and demo example (see: btRaycastVehicle::setCoordinateSystem). However I have been unable to find any recommendations on the best way adapt/convert the coordinate system in bullet, into the coordinate system that is inside the simulator.

My solution at the moment is to leave everything in Bullet as is, and attempt to simply rotate the coordinate system on the interface between Bullet and the simulator. Since the simulator has it's own sets of classes for quaternions and 3D vectors, I have tried to use the type conversion interface to also add the appropriate transformations (see the following code).

Code:
static const CQuaternion SIMULATOR_TO_BULLET =
CQuaternion(CVector3(0.0, 1.0, 0.0), CVector3(0.0, 0.0, 1.0));

static const CQuaternion BULLET_TO_SIMULATOR =
CQuaternion(CVector3(0.0, 0.0, 1.0), CVector3(0.0, 1.0, 0.0));

inline CVector3 BulletToSimulator(const btVector3& c_bt_vector) {
return CVector3(c_bt_vector.getX(), -c_bt_vector.getZ(), c_bt_vector.getY());
}

inline btVector3 SimulatorToBullet(const CVector3& c_a_vector) {
return btVector3(c_a_vector.GetX(), c_a_vector.GetZ(), -c_a_vector.GetY());
}

inline CQuaternion BulletToSimulator(const btQuaternion& c_bt_quaternion) {
return CQuaternion(c_bt_quaternion.getW(), c_bt_quaternion.getX(),
c_bt_quaternion.getY(), c_bt_quaternion.getZ()) * BULLET_TO_SIMULATOR;
}

inline btQuaternion SimulatorToBullet(const CQuaternion& c_a_quaternion_in) {
CQuaternion c_a_quaternion(c_a_quaternion_in * SIMULATOR_TO_BULLET);
return btQuaternion(c_a_quaternion.GetX(), c_a_quaternion.GetY(),
c_a_quaternion.GetZ(), c_a_quaternion.GetW());
}

However this still has some bugs (see below - objects are coming to rest at 45 degrees, despite only multiples of 90 degree rotations) and it isn't really all that efficient to be applying these quaternion rotations on every simulation step if unnecessary.
Attachment:
File comment: screenshot of the simulator showing entities resting at 45 degrees...

frame.png [ 36.64 KiB | Viewed 2015 times ]

So my question to all readers would be, how have you tackled this problem before and what recommendations can you make?

All the best,

allsey87

Top

 Post subject: Re: Integrating Bullet with a Z-axis-up SystemPosted: Thu Nov 08, 2012 2:52 pm

Joined: Fri Oct 26, 2012 1:50 pm
Posts: 33
Actually this solution does work nicely and can also avoid rotations (relatively costly compared to simple negations), the bug before was that I had forgotten to negate and switch the Z and Y axes in the Quaternion helper functions.

Code:
inline CVector3 BulletToSimulator(const btVector3& c_bt_vector) {
return CVector3(c_bt_vector.getX(), -c_bt_vector.getZ(), c_bt_vector.getY());
}

inline btVector3 SimulatorToBullet(const CVector3& c_a_vector) {
return btVector3(c_a_vector.GetX(), c_a_vector.GetZ(), -c_a_vector.GetY());
}

inline CQuaternion BulletToSimulator(const btQuaternion& c_bt_quaternion) {
return CQuaternion(c_bt_quaternion.getW(), c_bt_quaternion.getX(),
-c_bt_quaternion.getZ(), c_bt_quaternion.getY());
}

inline btQuaternion SimulatorToBullet(const CQuaternion& c_a_quaternion) {
return btQuaternion(c_a_quaternion.GetX(), c_a_quaternion.GetZ(),
-c_a_quaternion.GetY(), c_a_quaternion.GetW());
}

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 2 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 16 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities