unecessary new

This commit is contained in:
Renan Araujo
2019-03-22 13:20:18 -03:00
parent b23c316def
commit e7ac8ed094
13 changed files with 73 additions and 73 deletions

View File

@ -40,43 +40,43 @@ class Position {
Position.fromVector(b2d.Vector2 vector) : this(vector.x, vector.y);
Position add(Position other) {
this.x += other.x;
this.y += other.y;
x += other.x;
y += other.y;
return this;
}
Position minus(Position other) {
return this.add(other.clone().opposite());
return add(other.clone().opposite());
}
Position opposite() {
return this.times(-1.0);
return times(-1.0);
}
Position times(double scalar) {
this.x *= scalar;
this.y *= scalar;
x *= scalar;
y *= scalar;
return this;
}
double dotProduct(Position p) {
return this.x * p.x + this.y * p.y;
return x * p.x + y * p.y;
}
double length() {
return math.sqrt(math.pow(this.x, 2) + math.pow(this.y, 2));
return math.sqrt(math.pow(x, 2) + math.pow(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;
double nx = math.cos(angle) * x - math.sin(angle) * y;
double ny = math.sin(angle) * x + math.cos(angle) * y;
x = nx;
y = ny;
return this;
}
double distance(Position other) {
return this.minus(other).length();
return minus(other).length();
}
ui.Offset toOffset() {