# Getting the position after rotation

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

## Recommended Posts

How would I get the position after I rotate? In my last post I got my line to rotate around a point, now I need to know where the two points are when I rotate so I can test if they collide with another line. I suppose the math would be calculated with where the rotation point is.

##### Share on other sites
I have an idea but its only part of the solution. I would get the distance of the center of rotation to the two end points. From there I would get the next position of rotation with Sin and Cos. Since it is a radius, I tried using my circle formula and now my line is way out of wack. How would I get the angle? Lets say I have a vertical line with points 100, 100, to 100, 200, and the center of rotation is 100, 200. So it would rotate around the bottom point. If I rotated it to the right a point, the bottom would stay the same because there is no distance, what about the top point? If anyone could help me out it would be greatly appreciated. thanks.

##### Share on other sites
Simply multiply the points' locations by the transformation matrix used to rotate them. The results are the rotated locations. If you use OpenGL, then you have to compute the transformation matrix yourself. If you use D3D, then you already have the transformation matrix.

##### Share on other sites
How would you do that.
new_X1 = x1 * RotationMatrix
new_Y1 = y1 * RotationMatrix
new_X2 = x2 * RotationMatrix
new_Y2 = y2 * RotationMatrix

Or do i do it with the MatrixMultiply function?

##### Share on other sites
How about D3DXVec3TransformCoord (if you're using d3d) or there should be an operator overload or function in your math library that does similar.

##### Share on other sites
It gives me incorrect positions when I use that, maybe I'm doing it wrong.

public override void OnRotate(){        Vector3 temp1, temp2, temp3, temp4;        temp2 = new Vector3();	temp4 = new Vector3();	temp2.X = m_x1;	temp2.Y = m_y1;	temp4.X = m_x2;	temp4.Y = m_y2;	temp1 = Vector3.TransformCoordinate(temp2, mRotation);	temp3 = Vector3.TransformCoordinate(temp4, mRotation);	SetPoints(temp1.X, temp1.Y, temp3.X, temp3.Y);}

[Edited by - cptrnet on June 22, 2005 5:04:40 PM]

##### Share on other sites
does anyone see what Im doing wrong?

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 18
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632662
• Total Posts
3007702
• ### Who's Online (See full list)

There are no registered users currently online

×