1
Graphics / set coordinates depending on rotation
« on: July 02, 2012, 11:48:30 am »
I am currently working on collision detection/effect with triangles and I've got it to work if they are not rotating..
I have made 2 variables for each corner, one for x and y. The problem I'm having is that when you rotate the triangle the values of the corners stays the same (they are not targeting the corners anymore therefor the collision detection function I have made does not work). So I tried to make it so that those values depend on what the rotation is. The radius of the triangle is 64 and the top corner is right in the center so I thought that if the rotation was 90 degrees the x values should be - 64. With that in mind I came up with this: x = center of triangle - (rotation/1.40625) the 1.40625 is 90/64. This indeed made it so that when the rotation was 90 the value of x was - 64, I later realized that I had made a line instead of a curve.
So how do I make x and y coordinates make the same curve as the rotation?
I have made 2 variables for each corner, one for x and y. The problem I'm having is that when you rotate the triangle the values of the corners stays the same (they are not targeting the corners anymore therefor the collision detection function I have made does not work). So I tried to make it so that those values depend on what the rotation is. The radius of the triangle is 64 and the top corner is right in the center so I thought that if the rotation was 90 degrees the x values should be - 64. With that in mind I came up with this: x = center of triangle - (rotation/1.40625) the 1.40625 is 90/64. This indeed made it so that when the rotation was 90 the value of x was - 64, I later realized that I had made a line instead of a curve.
So how do I make x and y coordinates make the same curve as the rotation?