**1**

###
#1
Members - Reputation: **128**

Posted 13 November 2012 - 08:11 PM

I saw a couple of articles on wikipeadia and other places about rotating shapes using Matrix.

I do not have much experience with Matrix in general, but I can do my reasearch.

Now the thing that I would love to make is, kind of my own rotating shape, from scratch in java.

I mean drawing everything without any help from any library and then using a rotational matrix (Sorry if the name is wrong!) and make a 3D picture. I already have done 2D graphics.

I would just love to go through the work and understand how exactly it works.

Thanks for the help, if possible.

###
#2
Members - Reputation: **1214**

Posted 14 November 2012 - 10:36 AM

Generally, an object will have it's vertices defined in local space. These vertices can be moved into a common space, often called "world" space, by using a transform.

For an example, take a unit cube, centered at origin. It's vertices will have coordinates ranging from -0.5 to +0.5 in each axis, XYZ. If we want to make a cube at <6,0,0> in world space, we take each vertiex and multiply it by a transform matrix, resulting in world space vertices ranging from +5.5 to +6.5 on the x axis.

A camera is simply another object in space, and we can use the second point in the first paragraph, to translate the world space vectors into the cameras local frame, often called view space. Continuing with the example above, If we want to view the cube, we could make a camera, and set it at origin, but looking down the X axis. The cameras world transform would transform the local XYZ axes to the world , so that the local Z axis is aligned with the world X, and the local X axis would be aligned with the world -Z. The inverse of that transform will take the world space vertices of the cube, and transform them into view space. Our cube in view space would now have x and y coords ranging from -0.5 to +0.5, with it's Z coordinates ranging from 5.5 to 6.5.

finally, projecting the 3d view space coordinates into screen space can be done with whats known as a projection matrix, so that objects farther back appear smaller and so forth. this would make the far side of the cube slightly smaller than the near side.

I would suggest finding a good resource such as http://www.euclideanspace.com/ to get a better, more visual idea of what is going on. When I first learned about matrices it made 0 sense to me. Thanks to the explanations Martin Baker gave, I was able to piece together a basic 3d renderer in PHP, which gave me enough confidence to start tackling DirectX and I'm still going strong.

###
#3
Members - Reputation: **154**

Posted 15 November 2012 - 05:59 AM

http://www.khanacademy.org/math/trigonometry/v/polar-coordinates-1 Check the ones on polar coordinates.

Once you understand that, you should know that rotation matrices are just a fancy way of doing those operations. Matrices are just used for performance, you do not need them to implement transformation. There are many people who get introduced to matrices before they even know (or they forgot) how transformation works, and because of that many people find the concept confusing.

**Edited by Xcrypt, 16 November 2012 - 04:34 AM.**

###
#4
Members - Reputation: **127**

Posted 18 November 2012 - 08:46 PM

The best way to think of matrices as some kind of black box, a function, that takes a vector as an input and ouputs a vector that has been transformed. With 4x4 matrices, which is what he use in video games, because they allow us to use the magical homogenous transormation, the input will be a 4x1 vector. Just set the w component to 1 for positional transformations, and you're good to go. Don't worry about setting w to antyhing else.

Now the reason I said I had bad news, is because if you truly want to understand matrices, you got to go to college to learn about linear algebra. I'm sorry to say it, but without a strong mathematical background if you tried to just read about matrices you'd think they are just some mystical force in the universe that somehow just work. There are all sorts of interesting reasons why we can pull off what we do in video games using matrices, such as orthogonal transformations, and the like, but it really takes a strong mathematical background to get understand it.

I will say this, however, if you get a degree in mathematics, you can still get a job in video games, and also since you have a degree in math and not computer science, people won't ask you to fix their computers all the time cause they don't know you know about computers.

###
#5
Crossbones+ - Reputation: **4032**

Posted 18 November 2012 - 09:32 PM

http://en.wikipedia.org/wiki/Trigonometric_identity#Angle_sum_and_difference_identities

As far as 3D geometry matrices go, they aren't mystical at all. Think of them as four vectors packed together. During multiplication with other matrices or vectors, the first three "vectors" inside the matrix modify the coordinate axis (X,Y,Z) directions, and the last one modifies where the "origin" is. In this form, a matrix "converts coordinate spaces".

You can render the contents of a matrix to the screen and visualize it by splitting the matrix down into each vector and then using those to plot lines on the screen. If you were to render a standard 3D model using the matrix, you would notice that it would be rendered at the same position and orientation as the three lines.

###
#6
Crossbones+ - Reputation: **6974**

Posted 18 November 2012 - 09:47 PM

Some matrix operations may require college-level linear algebra to understand, but rotation certainly isn't one of them. 8th grade math was all I needed to understand them...Now the reason I said I had bad news, is because if you truly want to understand matrices, you got to go to college to learn about linear algebra. I'm sorry to say it, but without a strong mathematical background if you tried to just read about matrices you'd think they are just some mystical force in the universe that somehow just work. There are all sorts of interesting reasons why we can pull off what we do in video games using matrices, such as orthogonal transformations, and the like, but it really takes a strong mathematical background to get understand it.

@OP: Do you understand how 2D rotation matrices work? It's much easier to understand 3D rotation matrices if you understand 2D rotation matrices, but I don't want to go over 2D matrices if you're already familiar with them, and I won't talk about 3D rotation matrices if you don't understand 2D rotation matrices.

Also, you said you haven't done much with matrix math. I suggest you check out the Khan Academy to learn about matrix math. Start with the first video. I suggest watching the first 9 videos. The others are optional, as far as understanding rotation matrices goes.