**0**

# The maths behind the rotations

Started by bigdilliams, Oct 27 2012 10:25 AM

6 replies to this topic

Sponsor:

###
#2
Members - Reputation: **415**

Posted 27 October 2012 - 11:52 AM

Are you familiar with matrix multiplication? If not I suggest you have a look into it. Something that also helped me understand rotations was doing simple vector rotations (cameras are a good example).

Edit:

Possibly learning how to use cos and sin to move around the bounds of the unit circle would be a good start. http://en.wikipedia.org/wiki/Unit_circle

If you are standing in the middle of the unit circle looking directly right (x = 1, y = 0) and say you want to rotate 45 degrees you would get those coordinates like this

This will give you the new direction at 45 degrees from the original direction. Think about it, cos(90) gives a value of 0. This is correct because if we rotated 90 degrees, the x component of the vector (direction) would be 0, because it would be pointing directly up (x = 0, y = 1).

Hope this helps a bit, rotations are very tricky to start off learning.

Edit:

Possibly learning how to use cos and sin to move around the bounds of the unit circle would be a good start. http://en.wikipedia.org/wiki/Unit_circle

If you are standing in the middle of the unit circle looking directly right (x = 1, y = 0) and say you want to rotate 45 degrees you would get those coordinates like this

x = cos(45.0); y = sin(45.0);

This will give you the new direction at 45 degrees from the original direction. Think about it, cos(90) gives a value of 0. This is correct because if we rotated 90 degrees, the x component of the vector (direction) would be 0, because it would be pointing directly up (x = 0, y = 1).

Hope this helps a bit, rotations are very tricky to start off learning.

**Edited by rocklobster, 27 October 2012 - 12:06 PM.**

###
#3
Prime Members - Reputation: **2061**

Posted 27 October 2012 - 02:41 PM

you have attached a transformation, where p' is the transformed vector of p by the rotation matrix that you just showed

as stated above you'll need to understand the maths behind this

you can't just take shots in the dark with this and learn only the basics, because this knowledge is crucial to game development

the matrix shows you a homogenous transformation matrix, a basic rotation around x-axis in a 2D system R

hence the 3rd column (tx, ty, w), where w is the homogenous coordinate

you can learn all about this in many tutorials on the internet with a quick search

this isn't something that helpful people on gamedev can explain to you in 1-10 posts

as stated above you'll need to understand the maths behind this

you can't just take shots in the dark with this and learn only the basics, because this knowledge is crucial to game development

the matrix shows you a homogenous transformation matrix, a basic rotation around x-axis in a 2D system R

_{2}hence the 3rd column (tx, ty, w), where w is the homogenous coordinate

you can learn all about this in many tutorials on the internet with a quick search

this isn't something that helpful people on gamedev can explain to you in 1-10 posts

**Edited by Kaptein, 27 October 2012 - 02:51 PM.**

###
#4
Members - Reputation: **1526**

Posted 27 October 2012 - 02:51 PM

If you start with an identity matrix:

1 0 0 0 1 0 0 0 1That will simply scale x with 1, y with 1 and z with 1. If you look at the next matrix, with only one number:

0 1 0 0 0 0 0 0 0This will scale y with 1 and add it to x. But x was scaled with 0 this time, so the only things that remains from this transformation is the value of y moved to x, while y and z is cleared. Now look at this:

0 0 0 1 0 0 0 0 0It is almost the same thing, but it will scale y with 1 and copy it to x, while scaling the old y with 0. So this time, y is moved to x. This is possible to combine. The following:

0 1 0 1 0 0 0 0 0Will thus swap x and y. Now we are getting closer to a rotation. Rotating 90 degrees around the z axis (in a right handed coordinate system) is the same as moving x to y while moving -y to x. That would be:

0 -1 0 1 0 0 0 0 0If you set alpha to 90 degrees in your example, you will see that this is what you get.

###
#5
Members - Reputation: **118**

Posted 27 October 2012 - 03:17 PM

Ok, this is really a topic, wich can't be explained in 1-10 post. I was learning the whole day about vectors, scalars, matrices and so on. Now I got some good knowledge and in a few hours I will understand this completly. Nevertheless, I understood those replys and they were helpful.

Thank you.

Thank you.

**Edited by bigdilliams, 27 October 2012 - 03:19 PM.**

###
#6
Members - Reputation: **1526**

Posted 27 October 2012 - 05:28 PM

There are some additional key things about matrices you should also learn, as you are probably going to use them:

If you have an object you want to translate out into world coordinates and then rotate it, you have to multiply each vertex v as in T*R*v. If you would have done R*T*v, you would first translate it out to the "right position", but then rotate the whole translated vector.

- Matrix multiplication is associative, but not commutative.
- A transformation matrix can combine rotation, scaling and translation at the same time, for a single matrix.
- Matrix multiplication has the effect as if the rightmost transform is done first. To understand what the matrices A, B and C is going to do to vector v in A*B*C*v, you can see it as the transformation in C is applied to v first, then B and last A.

If you have an object you want to translate out into world coordinates and then rotate it, you have to multiply each vertex v as in T*R*v. If you would have done R*T*v, you would first translate it out to the "right position", but then rotate the whole translated vector.

###
#7
Members - Reputation: **149**

Posted 28 October 2012 - 04:59 PM

This answer is not specifically to the parner who made the question. Might even be for myself.

Man, the hardware just makes an illusion, after all. Don't get nuts about that or about how hard it is to grip the source of an specific equation/function as if you had to imagine it based on its results instead of how it works in a specific case, binded for a purpose (math alone is steryle but is amazing when joins its functions in a purpose to work as an

What those funcions have worthing (trigonometric) is that they return something between a range in a fixed way (what comes x goes out y, always), bouncing from up to down (or left/right, back/forth, -1..1, sun and moon, black to white, whatever defined and represented as a - mostly required smooth- transition).

What you see in the screen is a composition resulting from a specific time changing parameters that result in a scene created ( I am not going out of the scope since the "bones" of the issue ARE the mathematical functions). A simulation as how hardware works is no magic but a bunch of tricks and those trigonometric functions are nothing but this:

http://www.youtube.com/watch?feature=player_detailpage&v=s1eNjUgaB-g

ACTUALLY a bounce. ACTUALLY. Other kinds of functions represent (because they act as) other natural phenomenons (as a steady grow in 2 dimensions done by a square or three dimension done by a cube), going parallel (as simulation) to what happens in nature, chained to other functions based on natural results of natural interactions of the aspect (variable) you are seeking for. That is directed/aimed functionality (with functions being its "artifacts", not its purpose - despite being a purpose as language to computers).

You may not grip the math as a plotted dropping results of specific variables flowing thorugh functions to define spatial conditions because it renders too fast. If you could see the rendering not as fast, you could then see how the interactions lead the results into known ways of using trigonometry to simulate movement (riding a bicycle is somewhat like - you know the steps but speed makes it work). Don't fall into the functions as if they were an "identity of a transformation" by its declaration but take it slow to see that every piece of a function is an independent possibility bounded specifically to act as a part of a simulation of phenomenon either in literal meanings (direct rendering) or flow control (function direction/parameter). What you see in an algebric expression is an articulation or an identity to a natural event at last, in its minimal aspect known/identifiable.

There is no physical limit for simulation.

The results you see is just the attenuations/vectorizations(perspective adjustments) of the same functions based on another variations, all computed in a way to APPEAR that there is a WORLD being drawn and not just "

If algebra is like the sun for you,

Your vision shall not be the same as the Marionette (I hope) but the handler (who has nothing more than a few strings and sticks but, by his hability, can make a beautiful world to entertain people - math just have numbers and its transformations.. single or chained functions based on nature, or not):

http://www.youtube.com/watch?feature=player_detailpage&v=SPBm8I7hoBQ

Sorry for my way of explaining, might not be good but, may help.

Man, the hardware just makes an illusion, after all. Don't get nuts about that or about how hard it is to grip the source of an specific equation/function as if you had to imagine it based on its results instead of how it works in a specific case, binded for a purpose (math alone is steryle but is amazing when joins its functions in a purpose to work as an

**analogy of the nature - in this case, resulting graphical analogy in heterogeneous equations**).What those funcions have worthing (trigonometric) is that they return something between a range in a fixed way (what comes x goes out y, always), bouncing from up to down (or left/right, back/forth, -1..1, sun and moon, black to white, whatever defined and represented as a - mostly required smooth- transition).

What you see in the screen is a composition resulting from a specific time changing parameters that result in a scene created ( I am not going out of the scope since the "bones" of the issue ARE the mathematical functions). A simulation as how hardware works is no magic but a bunch of tricks and those trigonometric functions are nothing but this:

http://www.youtube.com/watch?feature=player_detailpage&v=s1eNjUgaB-g

ACTUALLY a bounce. ACTUALLY. Other kinds of functions represent (because they act as) other natural phenomenons (as a steady grow in 2 dimensions done by a square or three dimension done by a cube), going parallel (as simulation) to what happens in nature, chained to other functions based on natural results of natural interactions of the aspect (variable) you are seeking for. That is directed/aimed functionality (with functions being its "artifacts", not its purpose - despite being a purpose as language to computers).

You may not grip the math as a plotted dropping results of specific variables flowing thorugh functions to define spatial conditions because it renders too fast. If you could see the rendering not as fast, you could then see how the interactions lead the results into known ways of using trigonometry to simulate movement (riding a bicycle is somewhat like - you know the steps but speed makes it work). Don't fall into the functions as if they were an "identity of a transformation" by its declaration but take it slow to see that every piece of a function is an independent possibility bounded specifically to act as a part of a simulation of phenomenon either in literal meanings (direct rendering) or flow control (function direction/parameter). What you see in an algebric expression is an articulation or an identity to a natural event at last, in its minimal aspect known/identifiable.

There is no physical limit for simulation.

**Don't get functions as fetish without understanding its limits and how they are connected and the pratical purpose.**The results you see is just the attenuations/vectorizations(perspective adjustments) of the same functions based on another variations, all computed in a way to APPEAR that there is a WORLD being drawn and not just "

**chained reactions of known results based on observed motions in reality that goes in just ONE DIMENSION for EACH VARIABLE**, positioned in a 2 dimensional space.**2 (even for 3D graphics)**.". Don't grip the world, the simulation is**PURE ARTIFACT of reality, made by mind**. Don't go believing that there is a magic for "deep simulation" in the functions because there is no deep, just a parameter changing how a variable changes based on a simbology that turns a number into a fraction of another and THAT IS THE MAGIC: A number changing others based on its own value and by that change in especific and isolated variables, shifting up/down, reducing lengths of lines, affecting sizes, TURNING/TREATING X into/as Z, Z into/as Y, Y into/as X and causing the effect of rotation/flipping based on simple substitution (each matrix used can use**anything as anything**, by any parameters based on any source - anything in this case is NUMBERS that can be vectors/scalars or those "normals" that put z into z, x into x and y into y again**to close the circus**). I swear again: THERE IS NO REAL TRANSLATION, DEPTH, SCALE, ROTATION or whatever: what you see is a number changing another number to appear a scene, all based on an immitation of what would happen in reality (the "world" is just a relation between functions:*no matter how beautiful or weird an equation/function may appear because it doesn't work by itself and if the real condition from where it was concepted changes, the equation might change too - the conception of a function is the real art/synthesis, its utilization as graphics is, amazingly,*).**just artifact of math - in analogy to nature**If algebra is like the sun for you,

**don't look at the sun**. See how it was made and you might understand (the many aspects of reality that math simulates and how they join to result in a variable).Your vision shall not be the same as the Marionette (I hope) but the handler (who has nothing more than a few strings and sticks but, by his hability, can make a beautiful world to entertain people - math just have numbers and its transformations.. single or chained functions based on nature, or not):

http://www.youtube.com/watch?feature=player_detailpage&v=SPBm8I7hoBQ

Sorry for my way of explaining, might not be good but, may help.

**Edited by Caburé, 31 October 2012 - 11:17 AM.**