# Problem with rotationmatrices

## Recommended Posts

zorek    122
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

##### Share on other sites
ury    476
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}

##### Share on other sites
tthibault    100
Try the second one it mentions:

R = cos     -sinsin     cos

##### Share on other sites
zorek    122
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