Skip to content

Commit

Permalink
Vec3Arg: add the length() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 23, 2024
1 parent 6831fa0 commit c0a675d
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/Vec3.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,19 @@ public boolean isNormalized(float tolerance) {
}
}

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

return result;
}

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

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

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

0 comments on commit c0a675d

Please sign in to comment.