From 25efc8b5247a1e81a2739d537aea4747445e62f3 Mon Sep 17 00:00:00 2001 From: stephengold Date: Thu, 20 Feb 2025 06:00:29 -0800 Subject: [PATCH] Vec3Arg: add the isFinite() method --- .../java/com/github/stephengold/joltjni/Vec3.java | 14 ++++++++++++++ .../stephengold/joltjni/readonly/Vec3Arg.java | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/stephengold/joltjni/Vec3.java b/src/main/java/com/github/stephengold/joltjni/Vec3.java index f907e378..1fd39199 100644 --- a/src/main/java/com/github/stephengold/joltjni/Vec3.java +++ b/src/main/java/com/github/stephengold/joltjni/Vec3.java @@ -574,6 +574,20 @@ public float getZ() { return z; } + /** + * Test whether the vector contains infinities or NaNs. The vector is + * unaffected. + * + * @return {@code false} if one or more infinities or NaNs, otherwise + * {@code true} + */ + @Override + public boolean isFinite() { + boolean result + = Float.isFinite(x) && Float.isFinite(y) && Float.isFinite(z); + return result; + } + /** * Test whether the vector contains NaNs. The vector is unaffected. * diff --git a/src/main/java/com/github/stephengold/joltjni/readonly/Vec3Arg.java b/src/main/java/com/github/stephengold/joltjni/readonly/Vec3Arg.java index bc412be0..79e819e3 100644 --- a/src/main/java/com/github/stephengold/joltjni/readonly/Vec3Arg.java +++ b/src/main/java/com/github/stephengold/joltjni/readonly/Vec3Arg.java @@ -1,5 +1,5 @@ /* -Copyright (c) 2024 Stephen Gold +Copyright (c) 2024-2025 Stephen Gold Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -105,6 +105,15 @@ public interface Vec3Arg { */ float getZ(); + /** + * Test whether the vector contains infinities or NaNs. The vector is + * unaffected. + * + * @return {@code false} if one or more infinities or NaNs, otherwise + * {@code true} + */ + boolean isFinite(); + /** * Test whether the vector contains NaNs. The vector is unaffected. *