Retrieving Coordinates after rotations

Hi all,

I am rotating my camera using GlRotatef which works fine, but once I have rotated how do I get the new coordinates?, same goes for objects…

thanks

I don’t know, but I’m also very interested in it. If you find/get an answer, please let me know.

Thx

Hi !
Im working on a project that enables 3d navigation in a closed box. Ive created a class called camera and it is responsible for the rotation , and the different moves of the camera
if you think it is suitable for you !!

gvilir - Yes that would be great, if you could post it here or mail it, thanks.

Marc, once I find out I’ll tell you!, post me your mail address.

It’s not possible to get those transformed coordinates in OpenGL.
Just think the hardware case, how on earth could you access the data on the cards pipeline?
Or using several glVertex calls. IF there was some glGetTransformedVertex function, you should call it after each glVertex call. Doesn’t sound too nice.
I think it could be possible to make this with some kind of vertex array extension where you can pass OpenGL source and destination arrays. But afaik there is now such thing…

Hi david !
it seems that your email adress is wrong or something like this .

David, my e-mail-address is available in the profiles-section (left one of the four icons on top of postings of registered contributors). But here it is, too:
m.schneider@oe.uni-duisburg.de

thx for your offer

Just thought about something…

You could use glProject, but it’s not a very good solution…

I can’t believe what I saw ! Of course you can get the final coordinates of your points ! Have you ever heard of feedback mode ???
Antoche

Doh, the problem is that you can’t render while in feedback mode! So, you would have to switch into feedback mode, do the stuff you like, switch back to render mode…

Oh yes, and it’s in window coordinates.

[This message has been edited by Hude (edited 03-05-2000).]

gvilar, try this email echelonnine@hotmail.com

Everyone - thanks for replying, useful stuff.

>Doh, the problem is that you can’t render >while in feedback mode! So, you would have >to switch into feedback mode, do the stuff >you like, switch back to render mode…
>Oh yes, and it’s in window coordinates.

If you use glOrtho with window aligned to wolrd axes, then you get absolute coordinates. And switching Rendering mode to get some ccordinates is still faster than calculating transformed coordinates with your own algorithms.
Antoche

Yeah, and then you need to switch between those projections… but, what the heck… I think you’re right

The speed issue though. If you provide your own transformations, they’re done only once. If you use feedback and render mode, they’re done twice.

Btw, where do you guys need this stuff? Isn’t there any other way to solve the problem than get the transformed coordinates?

[This message has been edited by Hude (edited 03-06-2000).]

The reason why I needed the coordinates is because after a translation or rotation I needed to know where the camera is. A particular problem is that i need to move an object left and right from the camera’s point of view, no matter where the camera is pointing. I have managed to do it around the Y axis , but Im a bit stuck around the x and z axis.

Imagine a landscape. A tank is on this landscape, wich is not plane. So the tank follows the curve of the landscape to be more realistic (1 rotation with a random axe). Then the tank has a turret, wich can rotate upon an other axe (not necesseraly Y). Then on this turret, there is a cannon wich can rotate upon an other axe (not necesseraly X). And now, where is the end of the cannon ?
(you’ve 10 sec to answer, or you’re dead )
Now i think you see why i need that, Hu ?

Ooookay. Obviously it’s obvious. Thinking is generally a good idea, btw

Something else, is it really faster to use feedback and render modes than provide your own transformations? Normally we don’t need too many transformed vertices, so it wouldn’t really be a speed issue, right?

(thinking about discarding own transformations and D3D support… )

[This message has been edited by Hude (edited 03-06-2000).]

Originally posted by Antoche:
Imagine a landscape. A tank is on this landscape, wich is not plane. So the tank follows the curve of the landscape to be more realistic (1 rotation with a random axe). Then the tank has a turret, wich can rotate upon an other axe (not necesseraly Y). Then on this turret, there is a cannon wich can rotate upon an other axe (not necesseraly X). And now, where is the end of the cannon ?
(you’ve 10 sec to answer, or you’re dead )
Now i think you see why i need that, Hu ?

tank_meets_turret = a;
turret_center_of_rotation = b; // where the turret rotates on the tank
turret_meets_cannon = c; // loading end where
turret_end = d; // firing end, where the cannon rotates on the turret

rotate a to a degree on whatever axis. // point tank at direction

rotate c around b on whatever axis // set up the turret direction

rotate d around c on whatever axis. // you now have the (x,y,z) for the firing end of your cannon.

Assuming your using circular rotations this formula can be used.

From: “Christian Froeschlin”
> Radius,
> Circle center position
> A start/end position on the circle cirumferance (x,y)

> rotate around a point>

> example Radius = 10
> Center = 0
> Start = (-10,0)
> Number of points = 360 (smoothness of rotation)

x[n] = Center.X + Radius * cos( n * ( 2PI / NOL ) );
y[n] = Center.Y + Radius * sin( n * ( 2
PI / NOL ) );

for NOL = Number of points and n ranging from 0…NOL.

your points around are (x[n],y[n]) (x[n+1],y[n+1])

Note that x,y[0] = x,y[NOL].

Note that x,y[0] = x,y[NOL].

It’s best to give them as angles, if you have points
you can get the angles with atan2.

Then, instead of letting the angles run from 0 to 2PI
in NOL steps, let it run from start_angle to end_angle.
Take care with the wrapping at 2
PI.


Hope this helps some

Dans

[This message has been edited by dans (edited 03-09-2000).]