• Welcome to Dark Bit Factory & Gravity.
 

Rotating Rectangle

Started by mike_g, January 07, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

mike_g

I would like to find out how I could make a filled rotateable rectange function. My idea was that the function could have 5 parameters like: ROT_RECT(x, y, width, height, angle). which rotates around the center point. Help would be much appreciated.

Jim

The 4 points are

s = sin(angle)
c = cos(angle)

sw = width * s
cw = width * c

sh = height * s
ch = height * c

(x,y)
(x+cw,y+sw)
(x+cw-sh,y+sw+ch)
(x-sh,y+ch)



You can join them together with lines.  To fill it you really need a triangle drawing routine.

Jim

Challenge Trophies Won:

mike_g

Thanx. I got a function that draws filled triangles so I can just do two of them using co-ordinates got by that code.