123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|106|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Rotating Rectangle

Tue, 09 Jan 2007, 05:02
mike_g
I'm trying to write a function that draws a rectangle at any angle. Heres the code I have so far:

The first problem I have with this is that the rectangle rotates in 45 degree increments when I would like to be able to rotate it by any increment. Another problem is that the rectangle seems bigger than normal when drawn at a 45 degree angle. Also I would like it to rotate from the center of the shape instead of the corner. Can someone good at maths help me? Cheers.
Tue, 09 Jan 2007, 05:20
JL235
Your missing out the '#'s from your variables (at least: 's', 'c' and 'angle'), making them integers rather then floats. That is why it is not rotating correctly.
Tue, 09 Jan 2007, 05:32
mike_g
0_0 so I am. silly mistake. I should be able to code it to rotate from the centre myslef. Thanks.
Thu, 11 Jan 2007, 14:56
mike_g
I am still having problems...

I have been trying to change the point of rotation from a corner of the shape to the centre of it. I seem to have got it centred on one axis but cant centered on the other, and my rectangle now seems to be bigger than its meant to be o_0. Anyway I'm not so good at maths so I have sort of been guessing what to do, heres my code:

Since my code might be more confusing than helpfull. Heres the original rotating rectangle code with a little test prog:

Help with this would be much appreciated

Thu, 11 Jan 2007, 16:13
JL235
Here, I also included a 'rotatingPolygon' function, which will create a shape with multiple sides. However the corners are calculated from the centre of the shape, so it can make squares but not rectangles. I made that ages ago in Ruby.



I should also credit Noel Cower for his help in getting this to work.
Thu, 11 Jan 2007, 16:20
mike_g
Thanks diablo, trying to work that out was starting to do my head in. Now I have just got to put it to use