Add a rotate function
This commit is contained in:
@ -19,6 +19,14 @@ class vector {
|
|||||||
this.x += other_vector.x;
|
this.x += other_vector.x;
|
||||||
this.y += other_vector.y;
|
this.y += other_vector.y;
|
||||||
}
|
}
|
||||||
|
rotate(rad) {
|
||||||
|
var cos = Math.cos(rad);
|
||||||
|
var sin = Math.sin(rad);
|
||||||
|
//this.x = Math.round(10000*(this.x*cos-this.y*sin))/10000;
|
||||||
|
//this.y = Math.round(10000*(this.x*sin+this.y*cos))/10000;
|
||||||
|
this.x = this.x*cos-this.y*sin;
|
||||||
|
this.y = this.x*sin+this.y*cos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class node {
|
class node {
|
||||||
|
Reference in New Issue
Block a user