Thread: Rotation Equations've Got Me Stumped.

1. Rotation Equations've Got Me Stumped.

I perfectly understand the simple yet inefficient rotation equations. Like to rotate on the z axis:

x=cos(°)*r
y=sin(°)*r

That's easy and all, but inefficient. If you rotate 89° on the z axis, when you then go to rotate on the y-axis, you have to re-calculate the radius again(which would end up being WAY smaller). But I don't get these equations which don't require any radius length for rotation:

x=cos(°)*x' - sin(°)*y'
y=sin(°)*x' + cos(°)*y'

As much as I've tried, I just don't get it. I fail to see how it works. Can someone please walk me through this? You might have to talk to me like I'm a 3-year-old for me to get it. :-\

2. Well I'm not sure where radius and all come's into play here because the radius of the rotation is not determined by these equations. It is determined by how much you translate the object from the origin prior to rotating it.

To find out why the rotation equations work simply plug and chug. You will get a feel for what is taking place quite easily.

And this:

x=cos(°)*r
y=sin(°)*r

Is not a rotation equation. It will only displace x and y from the origin based on the current angle and it will only displace x and y by a maximum of 1 unit. To add radius and increase the displacement from the origin you need this:

p(t)=p(start)+(v*t)

or:

Code:
```struct point2D
{
float x;
float y;
};

...
...
//_ray is assumed to be of unit length or normalized
void DisplacePointAlongRay(point2D _start,point2D _ray,float _distance,point2D &newpoint)
{

newpoint.x=_start.x+(_ray.x*_distance);
newpoint.y=_start.y+(_ray.y*_distance);

}```

What you posted only works if you use the origin as your starting point in all cases. But you are very close to figuring out why the second equation you posted works. Essentially you are rotating a ray.

To understand it set theta equal to 0,90,180, and 270 degrees and solve for x and y. Plot your results on graph paper. Now do this for all other angles. You should have a a unit circle centered around the origin on your graph paper.

3. I'm afraid I still don't quite get it. I ran angles through a loop and a function to give me points around an origin of 250, and when plotted, they did indeed make a circle...but I still don't really quite understand how and how this works to replace any radius you might have.

I tried just adding and subtracting the rays themselves, and that sorta got me a circle as well when I plotted the points of the added rays and such..but I still really don't get it. I don't understand the relationships between the rays and their sin()s and cos()s that make those two equations work in perfect harmony to form a circle around an axis.

4. I'm not bumping this. I remember reading this thread, and I wanted to actually give an answer but I got caught up with other things. I can easily show you where these equations come from

x'=cos(°)*x - sin(°)*y
y'=sin(°)*x + cos(°)*y

As much as I've tried, I just don't get it. I fail to see how it works. Can someone please walk me through this? You might have to talk to me like I'm a 3-year-old for me to get it. :-\
First, you have to know that when you rotate a point by exactly 90 degrees through a positive angle (counter clockwise!), the x component becomes the negative y component, and the y component becomes the x component. i.e:

(x,y) becomes (-y,x) after the point has been rotated 90 degrees through a positive angle.

Back to what you originally said:

I perfectly understand the simple yet inefficient rotation equations. Like to rotate on the z axis:

x=cos(°)*r
y=sin(°)*r
So, basically, you've got a position vector, and by using basic trig you've got the X and Y components of the position. In vector notation, this position is written as:

PositionVector = [x]cos(°)*r + [y]sin(°)*r

where [x] and [y] are mutually perpendicular unit vectors describing the basis you are rotating on. This is where things get tricky. You see, both [x] and [y] are vectors which have their own components, and to avoid confusion I am going to change their names to P (formally [x]) and Q (formally [y]). Writing these equations again for the position vector, you get:

PositionVector = P cos(°)*r + Qsin(°)*r

PositionVectorX = Px cos(°)*r + Qx sin(°)*r
PositionVectorY = Py cos(°)*r + Qy sin(°)*r

But, what is Q? Well, Q is actually P rotated by 90 degrees

Q = <-Py, Px>
This means Qx = -Py and Qy = Px

Putting this back into the equation above, you get:

PositionVectorX = Px cos(°)*r - Py sin(°)*r
PositionVectorY = Py cos(°)*r + Px sin(°)*r

Which is what you get above.

In polar coordinates, P is always defined as <1,0>, therefore the original equation you posted is really a simpler version of the real equation, because Py is zero. Therefore, you get:

PositionVectorX = Px cos(°)*r - 0* sin(°)*r
PositionVectorY = 0* cos(°)*r + Px sin(°)*r

which is:

PositionVectorX = cos(°)*r
PositionVectorY = sin(°)*r

which is the simplest form of the rotation equations.

If P + Q instead represents the old position (in worldspace) instead of unit vectors, then you can get rid of the r in those equations (which is what you'd realistically do in practice) and is exactly equivalent to:

x'=cos(°)*x - sin(°)*y
y'=sin(°)*x + cos(°)*y
edit (the next day): I'd like to point out something which might avoid later confusion. P and Q can be any vectors just as long as they are perpendicular. As I said, the easiest form is in polar coordinates where P is the X axis:
P = <1,0>

and Q is the y axis:
Q = <0,1>

But, they can be any vectors, just as long as they are mutually perpendicular to each other (orthogonal...the dotproduct between them will be zero). So, for example, P could be the unit vector which points 45 degrees from the X axis, i.e:

P = <.7071, .7071>

and Q is perpendicular to P:

Q = < -.7071, .7071>

Now, you can rotate vector P from it's current angle through 10 more degrees, such that the new vector will make an angle of 55 degrees from the X axis (the vector <1,0> ) by using the equations above.

Popular pages Recent additions