Skip to content

Commit

Permalink
QuatArg: add the isZero() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Feb 20, 2025
1 parent 9fa00fd commit a7b45c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/Quat.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ public boolean isNormalized(float tolerance) {
}
}

/**
* Test whether the quaternion is zero. The quaternion is unaffected.
*
* @return {@code true} if exactly zero, otherwise {@code false}
*/
@Override
public boolean isZero() {
boolean result = (w == 0f) && (x == 0f) && (y == 0f) && (z == 0f);
return result;
}

/**
* Return the length. The quaternion 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 @@ -90,6 +90,13 @@ public interface QuatArg {
*/
boolean isNormalized(float tolerance);

/**
* Test whether the quaternion is zero. The quaternion is unaffected.
*
* @return {@code true} if zero, otherwise {@code false}
*/
boolean isZero();

/**
* Return the length. The quaternion is unaffected.
*
Expand Down

0 comments on commit a7b45c8

Please sign in to comment.