Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / angles to rotation matrix and back again - there must be a better way!

Author
Message
Avan Madisen
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: The Castle Anthrax
Posted: 11th Sep 2004 08:14
Hi

I've searched this forum and found nothing mentioning the words "rotation matrix" so I have a question for TGC, and sorry if this has been covered before.

I've been playing around with a physics tutorial lately and I've come to the conclusion that the only way I can handle rotation is the silly and long-winded way.

What I know is that graphics engines use rotation matrices internally to speed up rotating the vertices of poly meshes for rendering (I'm assuming DBPro is no different). I've looked through the help files (I'm still using patch 5.4 since the online updating system causes me too much hassle to update every time a new patch comes along) and it looks like there is no way to transfer a rotation matrix directly onto an object or camera rather then passing the angles.

The reason I mention this is because being able to do that would greatly simplify my code and speed up my program. This is because the physics I'm using never uses angles of any kind, the closest it gets is the normals of a line in 3d space. So it makes it necessary to use a rotation matrix calculate the angles to use with the 'rotate object' and 'rotate camera' commands to make objects follow a rigid body correctly. The problem comes from the fact that the graphics system then goes from the angles back to the rotation matrix. If it was possible to just work out the rotation matrix and transfer that across to the objects and camera, it would help me a great deal.

Is this functionality something that has been considered for DBPro or is it already in one of the newer patches? A command like 'pass matrix to object rotation' and 'pass matrix to camera rotation' are what I'm thinking of, so once the command has been used, the data is moved and the matrix can be used for other things afterwards, so I don't need one matrix to every object.

Again, sorry if this has been covered before, it's just I couldn't find anything with the search.

Thanks

Avan

If you don't like what you see on tv, then change the channel!
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 11th Sep 2004 08:22
Lee has spoken from time to time in the past about being able to apply rotation matrices directly to the vertex lists in *.x files. However, I do not believe that functionality yet exists.

A good work-around is Wolf's EZrotate plugin. With this you can convert matrices to Euler angles and then apply those to the object in question. This is a little slower than applying the matrices directly but we're talking thousands if not tens of thousands of a second slower here. So in practice there is no problem whatsoever.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
Ron Erickson
Moderator
22
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 11th Sep 2004 10:51
Avan,
There is no way to natively apply a matrix to an object in DBpro. DBpro uses Euler angles for orientation of ALL objects. You are right that with what you are trying to do, it will be a bit slower than applying a rotation Matrix directly. As Philip mentioned though, you will probably NEVER see the speed difference.
As I mentioned to you in our last e-mail, both EZrotate Basic and EZrotate Enhanced have the ability to do the conversion for you. EZrotate Enhanced has some major speed optimizations over EZrotate Enhanced (also mentioned in the e-mail). Still, I bet either version will work for you.

Regards,
Ron ~ a.k.a. WOLF

EZrotate!
Tokamak Physics Wrapper!
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Sep 2004 11:28
Actually if you are set on using DBP 5.4 only the basic version will work as I'm told you need 5.6 final for the EZrotate Enhanced. I'm still using the trial of it and it owns . Not gonna get the enhanced version until they fix the compiler bugs in DBP 5.6 final.

Avan Madisen
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: The Castle Anthrax
Posted: 12th Sep 2004 10:20
Hmm, I was planning on waiting for pathc 5.7 before updating again, oh well, just have to see how things go.

However Wolf, I do have to question the what you say about "it will be a bit slower than applying a rotation Matrix directly. As Philip mentioned though, you will probably NEVER see the speed difference." I would've thought that translating a matrix into angles would be very cpu heavy, or does it cheat by using some kind of look-up table? I doubt that actually considering the ammount of memory it'd probably require.

Anyway, thanks for the help.

Avan

If you don't like what you see on tv, then change the channel!
Ron Erickson
Moderator
22
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 12th Sep 2004 10:31
No, no look up tables. Handling math routines on PC's is fast these days. As long as the routines are well written, things work pretty well.
For example, imagine all of the math that happens with physics systems such as Newton and Tokamak. They are checking collision, response, friction, and on and on and on. I'm not sure if you seen my ragdoll demo that used Tokamak, but I bet it wouldn't have gained more than a FPS or two without the physics running at all. The number of objects on your screen, the polys rendered, the textures used and such are what KILLS your framerate. Pushing a few math calculations through in each loop is no real worry.

WOLF

EZrotate!
Tokamak Physics Wrapper!
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 13th Sep 2004 00:45
Changing matrices into euler angles is mathematically speaking pretty easy anyway. I remember even the old 8 bit machines back in the early 80s used to do that pretty damn quickly.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P3.2ghz / 1 gig / GeForce FX 5900 128meg / WinXP home
walaber
21
Years of Service
User Offline
Joined: 22nd Oct 2003
Location: Los Angeles, CA
Posted: 14th Sep 2004 18:44 Edited at: 14th Sep 2004 18:44
I do the same thing with my Newton wrapper- take the matrix from Newton and extract the Euler angles and position variables to place and rotate the object. There's just no other way to do it.

I'm just curious, what physics system are you working with? I know Novodex just became free for non-commercial projects, I was wondering how long before someone wrote a DBPro wrapper for it

the only other free library I can think of with no DBPro wrapper is ODE...

[edit] I just re-read your post and realized you might be writing your own physics routine based off a tutorial? [/edit]

Go Go Gadget DBPRO!

Athlon XP 2400+ || DDR-SDRAM 1GB || Nvidia GeForce 4 Ti4200 AGP 8x 128MB
Avan Madisen
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: The Castle Anthrax
Posted: 15th Sep 2004 06:07
@Wolf - hmm, I do see what you mean there, and I'll definately look into getting EZRotate Enhanced, could be rather useful by the sounds of it.

@Philip - Yeah, I remember a Mandlebrot viewer on the old BBC Micro Computer that could zoom in by many thousands! I've tried writing my own one but I quickly found the limit of standard floating point variables. LOL.

@Walaber - Yup, I'm writing my own physics engine in DBPro, am I insane? Completely! I'm using a tutorial written by someone who actually worked on physics for one of the Hitman games. Here's the link of you're interested in taking a look.

http://www.ioi.dk/Homepages/thomasj/publications/gdc2001.htm

Avan

If you don't like what you see on tv, then change the channel!

Login to post a reply

Server time is: 2025-05-31 00:33:47
Your offset time is: 2025-05-31 00:33:47