Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Used to rotate a normalized vector around a get point.
  3.  * @param double n Containing the rotation amount
  4.  * @return vector Containing the rotated form
  5.  */
  6. rotate: function (n) {
  7.     var
  8.         // Normalise the vector
  9.         v = this.normalize(),
  10.        
  11.         // Find the angle
  12.         ca = Math.cos(n),
  13.         sa = Math.sin(n),
  14.        
  15.         // And translate the position.
  16.         xx = v.getX() * ca - v.getY() * sa,
  17.         yy = v.getX() * sa + v.getY() * ca;
  18.  
  19.     return vector2(xx, yy);
  20. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement