From 2b79e04482b3fd2b2959161116c73ca5194e5d2c Mon Sep 17 00:00:00 2001 From: stephengold Date: Sat, 7 Dec 2024 19:22:04 -0800 Subject: [PATCH] RVec3Arg: add the length() method --- .../java/com/github/stephengold/joltjni/RVec3.java | 13 +++++++++++++ .../stephengold/joltjni/readonly/RVec3Arg.java | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/com/github/stephengold/joltjni/RVec3.java b/src/main/java/com/github/stephengold/joltjni/RVec3.java index bb733ff5..c9afef0f 100644 --- a/src/main/java/com/github/stephengold/joltjni/RVec3.java +++ b/src/main/java/com/github/stephengold/joltjni/RVec3.java @@ -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. * diff --git a/src/main/java/com/github/stephengold/joltjni/readonly/RVec3Arg.java b/src/main/java/com/github/stephengold/joltjni/readonly/RVec3Arg.java index badc2c34..469b79db 100644 --- a/src/main/java/com/github/stephengold/joltjni/readonly/RVec3Arg.java +++ b/src/main/java/com/github/stephengold/joltjni/readonly/RVec3Arg.java @@ -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. *