Getting the position after rotation

Started by
5 comments, last by cptrnet 18 years, 10 months ago
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.
If you insist on saying "DUH", try to make a post that makes a little more sense
Advertisement
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.
If you insist on saying "DUH", try to make a post that makes a little more sense
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
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?
If you insist on saying "DUH", try to make a post that makes a little more sense
How about D3DXVec3TransformCoord (if you're using d3d) or there should be an operator overload or function in your math library that does similar.
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]
If you insist on saying "DUH", try to make a post that makes a little more sense
does anyone see what Im doing wrong?
If you insist on saying "DUH", try to make a post that makes a little more sense

This topic is closed to new replies.

Advertisement