VBGamer |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Heres some code Carl (6 replies, 0 views) (2000-Jul-24) Heres the code, you might need to swap a couple of vertices around, but it should be OK.
Obviously you don't want to do the Sin and Cos calculations every time, just do it once and store them in a variable. Infact this can be optimised alot because a lot of the math is repeated.
Width and Height = The dimensions of the image.
Angle = Angle rotated by.
Position = coordinates of the center of the image.
Vertex(0).X = -Width * Cos(Angle) - Height * Sin(Angle) + Position.X
Vertex(0).Y = -Width * Sin(Angle) + Height * Cos(Angle) + Position.Y
Vertex(1).X = Width * Cos(Angle) - Height * Sin(Angle) + Position.X
Vertex(1).Y = Width * Sin(Angle) + Height * Cos(Angle) + Position.Y
Vertex(2).X = Width * Cos(Angle) + Height * Sin(Angle) + Position.X
Vertex(2).Y = Width * Sin(Angle) - Height * Cos(Angle) + Position.Y
Vertex(3).X = -Width * Cos(Angle) + Height * Sin(Angle) + Position.X
Vertex(3).Y = -Width * Sin(Angle) - Height * Cos(Angle) + Position.Y
|