Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Resize a rotate shape

1 view
Skip to first unread message

HellenicOne

unread,
Jun 18, 2009, 5:58:39 PM6/18/09
to
I am developing an application in which the user is allowed to draw
primitives on the screen (ellipses, rectangles, lines, polylines
etc).

The application allows a user to move, rotate, and resize a shape.
Everything works correctly, except when I attempt to resize a rotated
shape.

My rectangle and ellipse is expressed as a point array of size two.

Element->pt[0].x
Element->pt[0].y
Element->pt[1].x
Element->pt[1].y

The first point represents the top left point of my shape and the
second point the bottom right point of my shape. I can draw an ellipse
or rectangle just by knowing these two points.

The problem I am having is that rotation is expressed by:

x' = cx + (x * cos(Theta)) - (y * sin(Theta));
y' = cy + (x * sin(Theta)) + (y * cos(Theta));

As I am resizing the value of cx, cy is changing since the centre of
my shape is changing thus causing the shape to appear to "float"
across the screen instead of it being anchored (as in MS Word).

I tried removing the centre x, y coordinates from the equation and
just use (0,0) as the origin when the user is resizing a rotated
shape:

x' = (x * cos(Theta)) - (y * sin(Theta));
y' = (x * sin(Theta)) + (y * cos(Theta));

This seems to work correctly (shape remains anchored), but
unfortunately the entire shape moves to another location along the
perimeter of my imaginary circle with centre at (0,0).

Has anyone ever dealt with this problem before? Is there a way to
compensate for the shape being moved to another location? Or is there
another solution to this problem? I am not using matricies.

Thanks,

0 new messages