This content has been marked as final. Show 8 replies
Its creating a 'method' for a Vector object (in the older style of class definition), giving it a rotate method with an argument in degrees.
It changes the Vector's existing x and y properties ( in the 'with(this)' part of the code) based on the angle that was passed.
I don't know if it gives the correct results because I didn't check the math/trig but that's the interpretation of what I see. What exactly do you want to have explained in more detail?
the math is correct.
i know this code mean,but i really want to know the four lines,like this:
var ca = Math.cos(angle * Math.PI / 180); //what's this mean?
var sa = Math.sin(angle * Math.PI / 180); //and this.
var rx = x* ca - y*sa; //and this;
var ry = x* sa + y*ca; // and this;
en ,thanks very much!!!
angle is in degrees and multiplying by pi and dividing by 180 converts those degrees to radians.
the last two lines give the values rx,ry of a point x,y after rotation by angle degrees.
thanks your reply, my question is that why use this method to acculate the x and y ,!!
that's what i want to konw!
you would use the rotate method if you wanted to rotate a point.
ok，thanks very much
i think i will study the math again!!!
too bad that ,i can only choose one correct answer,
at last, i really thanks everyone who help me!