aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-14 20:20:57 +0100
committerSven Göthel <[email protected]>2024-02-14 20:20:57 +0100
commit52277dc625b515ecc3ff0d26ca05428f3d973427 (patch)
tree00e4349cd4eac6edbb1da09e6566e0ddf4346340
parent5488665474cc7b88577cedfca6416784f0fda3ba (diff)
VectorUtil.isConvex1(): Fix zero test and handle out-of-bounds
-rw-r--r--src/jogl/classes/com/jogamp/math/VectorUtil.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/jogl/classes/com/jogamp/math/VectorUtil.java b/src/jogl/classes/com/jogamp/math/VectorUtil.java
index 6af93ae6b..a3515e767 100644
--- a/src/jogl/classes/com/jogamp/math/VectorUtil.java
+++ b/src/jogl/classes/com/jogamp/math/VectorUtil.java
@@ -1092,7 +1092,7 @@ public final class VectorUtil {
// Find out the orientation of this pair of edges,
// and ensure it does not differ from previous ones.
final float w = bx*ay - ax*by;
- if( DoubleUtil.isZero(wSign) && !DoubleUtil.isZero(w) ) {
+ if( FloatUtil.isZero(wSign) && !FloatUtil.isZero(w) ) {
wSign = w;
} else if( wSign > eps && w < -eps ) {
return false;
@@ -1180,6 +1180,9 @@ public final class VectorUtil {
++offset; // 0, ...
v1 = polyline.get(cmod(offset, polysz)); // next on-curve vertex
} while( !v1.isOnCurve() && offset < polysz );
+ if( offset >= polysz ) {
+ break;
+ }
// Previous edge vector ("before"):
final float bx = v0.x() - vp.x();
@@ -1232,7 +1235,7 @@ public final class VectorUtil {
// Find out the orientation of this pair of edges,
// and ensure it does not differ from previous ones.
final float w = bx*ay - ax*by;
- if( DoubleUtil.isZero(wSign) && !DoubleUtil.isZero(w) ) {
+ if( FloatUtil.isZero(wSign) && !FloatUtil.isZero(w) ) {
wSign = w;
} else if( wSign > eps && w < -eps ) {
return false;