Skip to content

Commit a7b45c8

Browse files
committed
QuatArg: add the isZero() method
1 parent 9fa00fd commit a7b45c8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/java/com/github/stephengold/joltjni/Quat.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,17 @@ public boolean isNormalized(float tolerance) {
354354
}
355355
}
356356

357+
/**
358+
* Test whether the quaternion is zero. The quaternion is unaffected.
359+
*
360+
* @return {@code true} if exactly zero, otherwise {@code false}
361+
*/
362+
@Override
363+
public boolean isZero() {
364+
boolean result = (w == 0f) && (x == 0f) && (y == 0f) && (z == 0f);
365+
return result;
366+
}
367+
357368
/**
358369
* Return the length. The quaternion is unaffected.
359370
*

src/main/java/com/github/stephengold/joltjni/readonly/QuatArg.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2024 Stephen Gold
2+
Copyright (c) 2024-2025 Stephen Gold
33
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
@@ -90,6 +90,13 @@ public interface QuatArg {
9090
*/
9191
boolean isNormalized(float tolerance);
9292

93+
/**
94+
* Test whether the quaternion is zero. The quaternion is unaffected.
95+
*
96+
* @return {@code true} if zero, otherwise {@code false}
97+
*/
98+
boolean isZero();
99+
93100
/**
94101
* Return the length. The quaternion is unaffected.
95102
*

0 commit comments

Comments
 (0)