A Flash Developer Resource Site

1. ## Trigonometry

How does the trigonometry in this function work?? Math.cosD() and Math.sinD() are custom functions that return angles in degrees. Vector is a class with x and y properties.

Vector.prototype.rotate=function(angle){
var ca=Math.cosD(angle);
var sa=Math.sinD(angle);
with(this){
var rx=x*ca-y*sa;
var ry=x*sa+y*ca;
x=rx;
y=ry;
}
};

2. It just uses the standard formulae for rotating a point about the origin by an amount of "angle" degrees.

the formulas that actually do the rotating are the

var rx=x*ca-y*sa; and
var ry=x*sa+y*ca;

bits. Then it changes the old (x,y) of the vector to the new rotated ones. Did you want proof of the formula?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap