Advertisement Jump to content
Sign in to follow this  
noatom

Going between coord systems

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!