GeometryUtils: fix clockwise calculation (#704)

This commit is contained in:
Gustl22
2019-03-19 18:47:05 +01:00
committed by Emux
parent 1051aacc7c
commit 271cab1212
5 changed files with 26 additions and 17 deletions

View File

@@ -8,9 +8,10 @@ public class GeometryTest {
@Test
public void testIsTrisClockwise() {
// Coordinate system is LHS
float[] pA = new float[]{0, 0};
float[] pB = new float[]{1, 1};
float[] pC = new float[]{1, 0};
float[] pB = new float[]{1, 0};
float[] pC = new float[]{1, 1};
float area = GeometryUtils.isTrisClockwise(pA, pB, pC);
Assert.assertTrue(area > 0);
@@ -21,12 +22,13 @@ public class GeometryTest {
@Test
public void testIsClockwise() {
float[] points = new float[]{0, 0, 1, 1, 1, 0};
// Coordinate system is LHS
float[] points = new float[]{0, 0, 1, 0, 1, 1};
float area = GeometryUtils.isClockwise(points, points.length);
Assert.assertTrue(area > 0);
points = new float[]{0, 0, 1, 0, 1, 1};
points = new float[]{0, 0, 1, 1, 1, 0};
area = GeometryUtils.isClockwise(points, points.length);
Assert.assertTrue(area < 0);
}