3 Replies Latest reply on Oct 5, 2006 12:55 PM by kglad

# Finding point after rotation

Hi, having some math problems... hoping someone can help....

Lets say I have a rectangle (height > width). I need to know the bottom
middle point. That would be point(clipWidth / 2, clipHeight).
But I am having a hard time keeping track of this point after I rotate that
clip. If I rotate the clip 40 degrees (clip._rotation = -40), where on the
stage is that bottom middle point now?

I have searched the forums, and came up with alot of finding the angles, but
all seem to assume I know 2 points.
Closest I've gotten is using:
x=ClipWidth / 2 + Math.cos(angle)
y=ClipWidth / 2 - Math.sin(angle)

Sorry, I'm soooo rusty with math and hoping someone can push me in the right
direction.

I've created a simple test movie to try to get it working, with some tips
from another forum, here is what I have so far.
I have a movieclip 'myBox', which is 50X100, and located at 0,0 on the
stage. Then I put a circle movie clip 'myDot', which hopefully will be
following that bottom center point I'm trying to get at. Taking your
example, this is what it comes to:

var r=-45;
myBox._rotation = r;

var x = myBox._width / 2;
var y = myBox._height;

var c = Math.cos(r);
var s = Math.sin(r);

var rotX = c * x - s * y;
var rotY = s * x + c * y;

myDot._x = rotX;
myDot._y = rotY;

Thanks for any tips,
Jason

• ###### 1. Re: Finding point after rotation
the position of any point on your rectangle AFTER applying a rotation depends upon the registration point of your rectangle. (you should be able to see the effect yourself by changing your rectangle's registration point and rotating it.)

so, to specifically answer your question you must specify the location of your rectangle's registration point. however, in general, you can see that every point on your rectangle has a certain distance from and forms an angle (relative to the horizontal) to the registration point. after any rotation that point will be the same distance from the registration point and its new angle will be the some of the initial angle plus the rotation.
• ###### 2. Re: Finding point after rotation
The registration point is (0,0) top left. The _x and _y are unchanged when
rotating the clip.... is there something I'm leaving out?

news:eg3hdu\$6vf\$1@forums.macromedia.com...
> the position of any point on your rectangle AFTER applying a rotation
> depends
> upon the registration point of your rectangle. (you should be able to see
> the
> effect yourself by changing your rectangle's registration point and
> rotating
> it.)
>
> so, to answer your question you must specify the location of your
> rectangle's
> registration point.
>

• ###### 3. Re: Finding point after rotation
you can use the updateF() function below to return the x,y coordinates of any point on your rectangle. for example, if you have a rectangle with upper left registration point and instance name rect, the x coording of the bottom edge's midpoint after rotating angle degrees is;