I'm getting the same crazy, I don't know what's going on results using this.
Is there something I'm missing?

Yeah -- and without that, none of your previous attempts had a chance
to succeed. :)

_rotation takes degrees, i.e., where a full circle is 360. Math.sin
and Math.cos take radians, where a full circle is 2 * Math.PI. You
have to convert:

var rad = r / 180 * Math.PI;

then:

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

That's all. Sorry, I should have mentioned it.

Mark


On 10/5/06, Jason C Reynolds <[EMAIL PROTECTED]> wrote:
Hoping you can elaborate just a bit with this... I've created just a simple
test movie for this just using code in the timeline.
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 - myBox._width;
myDot._y = rotY - myBox._height;


I'm getting the same crazy, I don't know what's going on results using this.
Is there something I'm missing?

Thanks everyone for the replies, much appreciated!!!

----- Original Message -----
From: "Mark Winterhalder" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
Sent: Wednesday, October 04, 2006 7:19 PM
Subject: Re: [Flashcoders] Find point after rotation


>> Lets say I have a rectangle (height > width). I need to know the bottom
>> middle point. That would be point(clipWidth / 2, clipHeight).
>
> So we'll say:
> var x = clipWidth / 2;
> var y = clipHeight;
>
>> Closest I've gotten is using:
>> x=ClipWidth / 2 + Math.cos(angle)
>> y=ClipWidth / 2 - Math.sin(angle)
>
> That's pretty close already -- it's what you would use to draw a
> circle (by iterating the angle and connecting the resulting dots).
>
> What you need is those two values:
> var cos = Math.cos( angle );
> var sin = Math.sin( angle );
>
> Then do the following with x and y from above (your "vector" for the
> "rotation matrix"):
> var rotX = cos * x - sin * y;
> var rotY = sin * x + cos * y;
>
> rotX and rotY are your coordinates (relative to the rectangle clip's
> position on its parent clip).
>
> One more thing:
> _rotation is stored as one byte, so it's rounded to 360 / 255. That's
> something you will have to take in account for the angle if you want
> to be exact, easiest would be to read the angle from the _rotation
> property after you've changed that.
>
> HTH,
> Mark
>
>
>
>
> On 10/4/06, Jason C Reynolds <[EMAIL PROTECTED]> wrote:
>> 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. Right now I'm trying to figure out the radius of the
>> 'circle' that is formed while rotating, but that isn't going anywhere
>> (fast anway).
>>
>> Thanks for any tips,
>> Jason
>> _______________________________________________
>> Flashcoders@chattyfig.figleaf.com
>> To change your subscription options or search the archive:
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> Brought to you by Fig Leaf Software
>> Premier Authorized Adobe Consulting and Training
>> http://www.figleaf.com
>> http://training.figleaf.com
>>
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
>


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to