# Going between coord systems

This topic is 2081 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm using a left handed coordinate system,but,the physics engine I'm using uses a right handed coordinate system. By now,you probably know where I'm going.

I thought that if I always pass my coords unchanged,and convert the ones I get from the physics engine to a left handed sys,there would be no problem,yet there is.

For example:

When I try to create a displacement vector like: get x position from physics engine - old_x position from my engine I just get the right movement,but inversed(moving left will actually get you to right)

So I thought,wouldn't inversing the Z coord I get from the physics engine work? No,It doesn't. Would inversing all the coords I get from the physics engine work? No,Would creating the displacement vector normally(the one that moves inversed),and then just inversing the vector work? NO!

Some ideeas?

Edited by noatom

##### Share on other sites

There exists several left-handed or right-handed coordinate system. How your coordinate systems are defined?

##### Share on other sites

A general approach for that sort of thing is to create a transform (using 4x4 matrix) to transform one coord system to another. Then use M * (do physics stuff) * M-1

For instance:

Matrix M = transform-from-your-left-hand-to-physics-right-hand;

Matrix InvM = Inverse( M );

Vector physVec = localVec * M;

(do physics engine stuff with physVec)

localVec = physVec * InvM;

##### Share on other sites

It is also possible to use the C++ type system to help you. Define a vector type you use for your game and a different one you use to interface with the Physics system. You can provide conversion functions between them, which do the matrix multiplications that Buckeye described. That way you won't forget a conversion somewhere, because your compiler won't let you.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 12
• 9
• 9
• 25