Jump to content

Rotation matrix [Resolved]


Mumbles
 Share

Recommended Posts

Edit: I'm hoping this is the correct board for this. Since it is programming related, and this is the only programming board that does not say "Programming Leadwerks Engine with (language)"

 

As most people will know, Leadwerks is great, because positioning and rotating objects is nice and easy, no matrix multiplication to worry about...

 

Unfortunately, not all engines share this level of ease-of-use. As part of integrating a stand alone version of newton in to my project, there is a newton callback ... The TransformCallback. Basically, whenever an object changes position or orientation in the newton world, this callback is called so your graphics can reflect this change. What Newton does however, is give you a matrix containing 16 floats.

 

Now, if I have been reading correctly, elements 12, 13, and 14 are used for the position (and 16 can be ignored entirely). This leaves me with 12 floats (0-to-11) describing the rotation. I quickly read my uni notes on matrix multiplication (one of things I thought I would never use again). I'm now quite confident about multiplying matrices together, but my concern is. What should I be multiplying these floats by, in order to get 3 meaningful angles from that matrix?

 

Also, from observing the raw matrix output that newton gives me, elements 3, 7 and 11 are all zero, does this mean I should instead be forming a 3x3 matrix before doing any multiplication?

 

There's no shortage of articles on the Internet trying to teach people how to do it, but they don't really seem to be written in plain english, and the ones I keep stumbling across seem to assume that the reader already has an extensive knowledge of Open GL's inner working's. Sadly, because I'm a bit thick, I seem to be getting quite confused when trying to read just about any of them.

 

 

The console output of newton's matrix is as follows:

 

Transform callback

matrix element 0: 1

matrix element 1: 0

matrix element 2: 0

matrix element 3: 0

matrix element 4: 0

matrix element 5: 0.655827

matrix element 6: 0.754912

matrix element 7: 0

matrix element 8: 0

matrix element 9: -0.754912

matrix element 10: 0.655827

matrix element 11: 0

matrix element 12: 0

matrix element 13: -0.0534112

matrix element 14: -0.159811

matrix element 15: 1

 

As I said earlier, I'm using elements 12, 13 and 14 for the position, and that seems to be correct, I'm just having trouble figuring out how I get three angles from the first 12 elements. I'm also not sure if I should be using this matrix (with the zeros removed):

 

1         0         0
0         0.655827  0.754912
0         -0.754912 0.655827

 

Instead of this one (with the zeros left in):

 

1         0         0        0
0         0.655827  0.754912 0
0         -0.754912 0.655827 0

 

After that, I should a very basic Newton integration. A version of newton that I can also run in a graphic-less dedicated server. So I'm hoping someone can explain this to me in a way that even I can understand...

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Unfortunately, after reading that, I'm still confused. The section right at the end looks like the information I need, but it's suggesting that I should already know the angle. I get the idea that they are showing how to calculate the new position of a point after rotating it by a known angle.

 

Sadly, I don't know the angle. That the thing I've got to try and work out by processing the matrix that newton gives me, but it does seem to be suggesting that I leave zeros on the right hand size. It's also suggesting that I need elements 12-to-15, but after replacing 12, 13 and 14 with zero values.

 

 

It will be something very small that I'm not understanding (it always is), but until I know what I'm not understanding, I'll be completely clueless and stuck.

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Just use SetEntityMatrix.

 

Wow, thanks a lot. I never even saw that command before, and it's exactly the command I needed.

 

I was trying to do some acos() calls on some of the matrix elements :lol: . It was sort of working until it got to 180 degrees rotation, then it would go the other way. But thanks to you it works perfectly, keeps rotating in the same direction forever... :P

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...