# transformation and projection matrixes

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

## Recommended Posts

HI

I want to have matrix that makes the coordinates go X right and Y down. can someone provide me a matrix to do this?

If I understand correctly this matrix goes to setTransformMatrix() in libgdx.

sorry I'm not very good at matrixes.

thx!

##### Share on other sites

Simply, you have a vector in the xy plane, Vector (x, y, 0).  X and Y are some value.

You want to rotate on the Z axis effectively.  There are a few resources around, this is a great start even if its in opengl (http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/)

The libgdx example for creating a matrix is just down the page on this link -> https://github.com/libgdx/libgdx/wiki/Vectors,-matrices,-quaternions

Just remember, if you want to create any rotation and you have the normal (x) and the upvector (y), do the cross product and normalise the result.  You then have the rotation axis.

Hope this helps, matrices are not too scary, in fact there is a lot of cool tricks you can do with them.

##### Share on other sites

Thanks ErnieDingo. I went through those links and I believe only thing I need is this:

matrix.setToRotation(new Vector3(0,0,1),-90);

It works but the problem I'm having is that now all the sprites get rendered sideways. I could just rotate them but I believe there is cleaner way of doing this with matrixes. Or is there?

thx!

##### Share on other sites
Yes. But first did you normalize the axis you got from the cross product? And have you rotated the sprite enough? Did you play with other values but -90?

Also. You can create another rotation matrix and multiply them together to align in the correct plane.

But the way i determine the correct facing for the rotation. I use billboards in my 3d game which are similar to sprites. You may need to take the normal of your sprite when created and determine the angle between it and your screen normal. Cross product the 2 normals use the Then create a rotation matrix using the normalized axis and the angle determined.

Good luck

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633672
• Total Posts
3013273
×