Skip to content

Commit

Permalink
RVec3Arg: add the length() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Dec 8, 2024
1 parent 81315c2 commit 2b79e04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/RVec3.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ public boolean isNearZero(double tolerance) {
}
}

/**
* Return the length. The vector is unaffected.
*
* @return the length
*/
@Override
public double length() {
double lengthSq = lengthSq();
double result = Math.sqrt(lengthSq);

return result;
}

/**
* Return the squared length. The vector is unaffected.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public interface RVec3Arg {
*/
boolean isNearZero(double tolerance);

/**
* Return the length. The vector is unaffected.
*
* @return the length
*/
double length();

/**
* Return the squared length. The vector is unaffected.
*
Expand Down

0 comments on commit 2b79e04

Please sign in to comment.