Skip to content

Commit

Permalink
Add pow to Vector2D
Browse files Browse the repository at this point in the history
  • Loading branch information
BenG49 committed Jan 27, 2024
1 parent f3d75b1 commit 9973c08
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/com/stuypulse/stuylib/math/Vector2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ public Vector2D div(double divisor) {
return new Vector2D(this.x / divisor, this.y / divisor);
}

/**
* @param power power to raise magnitude of vector to
* @return result of raising the magnitude of the vector to the power
*/
public Vector2D pow(double power) {
return this.mul(Math.pow(magnitude(), power - 1));
}

/**
* @param other Vector2D to perform dot product with
* @return result of performing the dot product with the other Vector2D
Expand Down

0 comments on commit 9973c08

Please sign in to comment.