Skip to content

Commit

Permalink
QuatArg: add the isRotationIdentity() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Feb 24, 2025
1 parent 8ad8279 commit 522d2b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/Quat.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,22 @@ public boolean isNormalized(float tolerance) {
}
}

/**
* Test whether the quaternion represents an identity rotation. The
* quaternion is unaffected.
*
* @return {@code true} if the real component is a non-zero number and the
* imaginary components are all zero, otherwise {@code false}
*/
@Override
public boolean isRotationIdentity() {
if (w != 0f && !Float.isNaN(w) && x == 0f && y == 0f && z == 0f) {
return true;
} else {
return false;
}
}

/**
* Test whether the quaternion is zero. The quaternion is unaffected.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ public interface QuatArg {
*/
boolean isNormalized(float tolerance);

/**
* Test whether the quaternion represents an identity rotation. The
* quaternion is unaffected.
*
* @return {@code true} if the real component is a non-zero number and the
* imaginary components are all zero, otherwise {@code false}
*/
boolean isRotationIdentity();

/**
* Test whether the quaternion is zero. The quaternion is unaffected.
*
Expand Down

0 comments on commit 522d2b3

Please sign in to comment.