Problem with rotationmatrices

Started by
2 comments, last by zorek 18 years, 5 months ago
Hi! I'm currently working on a schoolproject where I have to use 3danimation for the first time. The problem is my insufficient mathknowledge. So over the last few days I've studied some basics about vectors and matrices. I think I understand most of it now, but I have some problem with the rotationtheory. The matrix for rotating an vertex in a 2dspace look like this: cos(a) sin(a) R= -sin(a) cos(a) (according to: http://mathworld.wolfram.com/RotationMatrix.html) I programmed this into my testclass (where translation already works) and tested it, it didn't work at all. The triangle just translated up and down. So I thought I'd try to test it mathematicly instead to see what was wrong: My triangle looks like this. Vertex1={0,0} Vertex2={1,1} Vertex3={2,0} I try to rotate the matrix with 60 degrees (or about 1.05radians), that makes the matrix look like this: 0.5 0.87 R= -0.87 0.5 Now multiply the vertexes: Vertex1={0*0.5+0*0.87 , 0*-0.87+0*0,5}={0,0} Vertex2={1*0.5+1*0.87 , 1*-0.87+1*0,5}={1.37,0.37} Vertex3={2*0.5+2*0.87 , 0*-0.87+0*0,5}={3.74,0} If this triangle was drawed, it would be an horisontally flipped triangle (slightly scaled). I know I've done something wrong with this thing, but I just can't figure out what... Thanks for your help! //David
Advertisement
Quote:
My triangle looks like this.
Vertex1={0,0}
Vertex2={1,1}
Vertex3={2,0}

Now multiply the vertexes:
Vertex1={0*0.5+0*0.87 , 0*-0.87+0*0,5}={0,0}
Vertex2={1*0.5+1*0.87 , 1*-0.87+1*0,5}={1.37,0.37}
Vertex3={2*0.5+2*0.87 , 0*-0.87+0*0,5}={3.74,0}


I don't know what's wrong with your program, but your computations are all wrong. It should be more like:

R*Vertex1 = {0*0.5+0*0.87 , 0*-0.87+0*0.5}={0,0}
R*Vertex2 = {1*0.5+1*0.87 , 1*-0.87+1*0.5}={1.37,-0.37}
R*Vertex3 = {2*0.5+0*0.87 , 2*-0.87+0*0.5}={1.0,-1.74}
Try the second one it mentions:

R = cos     -sinsin     cos
...and do not wildly extrapolate. Just because Saddam Hussein gassed Kurds in 1990 doesn't mean he eats babies' brains.
Quote:Original post by ury
Quote:
My triangle looks like this.
Vertex1={0,0}
Vertex2={1,1}
Vertex3={2,0}

Now multiply the vertexes:
Vertex1={0*0.5+0*0.87 , 0*-0.87+0*0,5}={0,0}
Vertex2={1*0.5+1*0.87 , 1*-0.87+1*0,5}={1.37,0.37}
Vertex3={2*0.5+2*0.87 , 0*-0.87+0*0,5}={3.74,0}


I don't know what's wrong with your program, but your computations are all wrong. It should be more like:

R*Vertex1 = {0*0.5+0*0.87 , 0*-0.87+0*0.5}={0,0}
R*Vertex2 = {1*0.5+1*0.87 , 1*-0.87+1*0.5}={1.37,-0.37}
R*Vertex3 = {2*0.5+0*0.87 , 2*-0.87+0*0.5}={1.0,-1.74}


Thank you! Now I can finally understand the logic in this.
It's quite odd though how I managed to get this far without the correct formula for multiplication ;)
//David

This topic is closed to new replies.

Advertisement