•      Sign In
• Create Account

## Going between coord systems

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1noatom  Members

919
Like
0Likes
Like

Posted 04 February 2014 - 04:13 AM

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, 04 February 2014 - 04:14 AM.

### #2apatriarca  Members

2316
Like
0Likes
Like

Posted 04 February 2014 - 06:57 AM

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

### #3Buckeye  GDNet+

10739
Like
1Likes
Like

Posted 04 February 2014 - 01:29 PM

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;

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

### #4Álvaro  Members

20272
Like
1Likes
Like

Posted 04 February 2014 - 02:53 PM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.