Question
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
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
