View Full Version : Some geometric problems :P

{MSX}

11-11-2004, 08:15 PM

Ok that's the problem:

i've my 3d car, with it's own orientation and position. I want it to reach a certain point by acting on the steer. The question is: how can i choose to steer left or right ?

I think the basic question is, given a rotation matrix, how can i say if the object lies on the left or on the right ?

Please help :P

Paulius

15-11-2004, 12:11 PM

To see if it?¢_Ts on the left or right you need to transform you?¢_Tre destination point so it?¢_~s coordinate system is the same as you?¢_Tre cars and check if it?¢_Ts X component is positive or not. To do the transformation you need to multiply that point by a translation matrix to move it?¢_Ts zero point to the cars position then by inverse or you?¢_Tre cars rotation matrix.

{MSX}

15-11-2004, 02:01 PM

To see if it?¢_Ts on the left or right you need to transform you?¢_Tre destination point so it?¢_~s coordinate system is the same as you?¢_Tre cars and check if it?¢_Ts X component is positive or not. To do the transformation you need to multiply that point by a translation matrix to move it?¢_Ts zero point to the cars position then by inverse or you?¢_Tre cars rotation matrix.

Ehm ok.. let's take a step at a time! :mrgreen:

I've the vector "position" of the car, the matrix "rotation" of the car and the "target" vector for where i want to drive to.

First, i obtain the 4x4 matrix that translate the origin to the car for both position and orientation, right ?

Then, i multiply the "target" by that matrix, and i get the "target" transformed to the new origin (the car). How do i do this multiplication?

Now, i check the X axis (that's easy.. :P)

Ok, i think i've understood the method.. now the problem is implementing it :P

Thank!

PS Paulius, maybe do you have a nice matrix calculation unit ? :P

PPS Anyone knows if the ODE matrices are compatible to the OpenGL ones ? Are they arranged in the same way in memory ?

Paulius

16-11-2004, 06:50 PM

First you need to make target?¢_Ts coordinate relative to the cars position (you could just subtract "position" from "target" for that), then you want to rotate the "target" by the opposite of you?¢_Tre car?¢_Ts rotation (to acieve that you have to multiply "target" vector by an opposite (transpose) of you?¢_Tre cars rotation matrix). You can try to build the rotation matrix from whatever you use to describe orientation, but as that matrix is useful in other places like collision detection you might as well use it to describe object orientation. I use Mike Lischke?¢_Ts geometry unit for matrix operations http://www.soft-gems.net/Graphics.php#Geometry

{MSX}

17-11-2004, 09:33 AM

First you need to make target?¢_Ts coordinate relative to the cars position (you could just subtract "position" from "target" for that), then you want to rotate the "target" by the opposite of you?¢_Tre car?¢_Ts rotation (to acieve that you have to multiply "target" vector by an opposite (transpose) of you?¢_Tre cars rotation matrix). You can try to build the rotation matrix from whatever you use to describe orientation, but as that matrix is useful in other places like collision detection you might as well use it to describe object orientation. I use Mike Lischke?¢_Ts geometry unit for matrix operations http://www.soft-gems.net/Graphics.php#Geometry

Ok, now it's clearer.. Thanks :P

One thing i didn't understood: why have i to use the inverse of the matrix instead of the matrix itself ?

What do i get if I use the non-inversed matrix ?

Paulius

17-11-2004, 09:56 AM

I used a wrong term, it's supposed to be not inverse but transpose. Why use an opposite rotation? Look at some point in front of you, if you turn youre head to the right and think youre head is the origin of the axis, then that point has relativelly rotated to the left (the opposite).

{MSX}

17-11-2004, 11:08 AM

I used a wrong term, it's supposed to be not inverse but transpose. Why use an opposite rotation? Look at some point in front of you, if you turn youre head to the right and think youre head is the origin of the axis, then that point has relativelly rotated to the left (the opposite).

:mrgreen: :mrgreen: :mrgreen: :mrgreen:

It works! :D :D I'm too happy :P

I confess that i thought i was going nowhere with this matrices.. Instead i just corrected the transpose and it worked :P

Now i've a nice car that follow the player wherever he goes :P

I've finally undestood how this obscure matrices work.

Thanks for your help Paulius

Powered by vBulletin® Version 4.2.5 Copyright © 2019 vBulletin Solutions Inc. All rights reserved.