Skip to content

Commit

Permalink
Vec3Arg: add the isFinite() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Feb 20, 2025
1 parent 990c8a8 commit 25efc8b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/Vec3.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 25efc8b

Please sign in to comment.