Adding a rotate method to Position and a drawWhere method to utils

This commit is contained in:
Luan Nico
2017-12-30 21:59:45 -02:00
parent fbaec30724
commit 5eee726d92
2 changed files with 16 additions and 0 deletions

View File

@ -22,4 +22,12 @@ class Position {
double length() {
return math.sqrt(math.pow(this.x, 2) + math.pow(this.y, 2));
}
Position rotate(double angle) {
double nx = math.cos(angle) * this.x - math.sin(angle) * this.y;
double ny = math.sin(angle) * this.x + math.cos(angle) * this.y;
this.x = nx;
this.y = ny;
return this;
}
}