Jump to content
• Advertisement

# Matrix rotation help

This topic is 3059 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hi Im currently working with my lecturers engine to build a game, and thus far its going well, right up until i try to do seperating axis theorum. the SAT code is fine however its how his engine transforms VBO's tahts the problem. i need all 4 corners of the vbo to test on the axes however he only provides one vector which refers to the center point of the vbo, now I can figure out what the inital vertices are of the vbo, but its when the vbo rotates....then it becomes a problem cause i dont know how to rotate the points im testing to match how it is on screen, so the testing will be rendered moot as the SAT is working with inaccurate data. So either someone can hopefully give me a quick run down of a way around this? cheers

#### Share this post

##### Share on other sites
Advertisement
Can you back up and describe the problem you're trying to solve? i.e. why are you running SAT on the transformed points instead of the untransformed point?

Otherwise you just need to apply the same matrix transforms to the reconstructed world-space points that happen in the renderer: i.e. grab the projection matrix and the model view matrix and transform the world-space points by those matrices. This will give you the screen space coordinates

-me

#### Share this post

##### Share on other sites
okay well, As i mentioned, everything is drawn with VBO's in a scene-graph. to manipulate the VBO translation and orientation, it will need a transformation node before it. However that transform node as far as i can tell give you two variables to work with....a 2DVector for position x and y and a float for rotation. the VBO's are always drawn with the 2Dvector at its center rather than the bottom left but its the only point im given access too. If i want SAT to work im going to need all 4 points. now if the vbos doesent rotate its easy to know where the vertices are it would be

(from bottom left going clockwise)
A = DS2DVectorMake( rectangle.origin.x - rectangle.size.width/2, rectangle.origin.y - rectangle.size.height/2 );B = DS2DVectorMake( rectangle.origin.x, rectangle.origin.y + rectangle.size.height );C = DS2DVectorMake( rectangle.origin.x + rectangle.size.width, rectangle.origin.y + rectangle.size.height );D = DS2DVectorMake( rectangle.origin.x + rectangle.size.width, rectangle.origin.y );

so if the vbo never rotated awesome, the code would work, however if it rotates i need to obviously rotate these points with it so they stay relative to its rotation, my quandary comes at..how do i rotate them? i will post my lecturers code on request if that will help. oh also we dont work with the projection and model view matrix, thats all handled for me hence me getting in a bit of a confuzzle.

cheers

edit: sorry for the late reply i was knackered and fell asleep at the computer

#### Share this post

##### Share on other sites
You don't need to rotate the corners of the rectangles in order to perform the SAT. All you really need is the origin (position), the rotation angle, and the width and height.

The SAT for oriented boxes generally expects the boxes to be represented as follows:

1. A center point.
2. Two (or three, in 3-d) orthonormal basis vectors.
3. The extents (half-width/height/depth) in each dimension.

The fact that your quads appear to have the origin at a corner complicates things a little. I don't know if you have the latitude to change this, but it's almost always easier (IMO) if sprites are represented with the origin at the center (it makes it easier to rotate them for rendering, and for collision detection purposes).

It's not the optimal approach, but it is possible to perform the SAT using the actual transformed vertices, if you want to do it that way. If you want to get the transformed vertices, you'll need to transform them manually as described by Palidine.

#### Share this post

##### Share on other sites
well your in luck, the quads position is from the centre...but as far as my SAT calculation goes dont i need to project the corners of the shape onto an axes? hence why i made those 4 points from the origin

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
19
5. 5
• Advertisement

• 14
• 26
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631770
• Total Posts
3002251
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!