Skip to content

Commit 36f4556

Browse files
authored
WWMath unit test (NASAWorldWind#205)
1 parent 84175c2 commit 36f4556

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) 2012 United States Government as represented by the Administrator of the
3+
* National Aeronautics and Space Administration.
4+
* All Rights Reserved.
5+
*/
6+
7+
package gov.nasa.worldwind.util;
8+
9+
import static org.junit.Assert.*;
10+
import org.junit.Test;
11+
import org.junit.runner.RunWith;
12+
import org.junit.runners.JUnit4;
13+
14+
import gov.nasa.worldwind.geom.Vec4;
15+
16+
@RunWith(JUnit4.class)
17+
public class WWMathTest {
18+
19+
private static final double DELTA = 1e-9;
20+
21+
/**
22+
* Test triangle normal computation
23+
*/
24+
@Test
25+
public void testParseTimeString() {
26+
Vec4 v1 = new Vec4(26, 2, 1);
27+
Vec4 v2 = new Vec4(26, 2, 13);
28+
Vec4 v3 = new Vec4(12, -23, 13);
29+
Vec4 expectedNormal = new Vec4(0.8725060159497201, -0.48860336893184325, 0.0);
30+
Vec4 normal = WWMath.computeTriangleNormal(v1, v2, v3);
31+
assertEquals("Normal computation 1 X", expectedNormal.x, normal.x, DELTA);
32+
assertEquals("Normal computation 1 Y", expectedNormal.y, normal.y, DELTA);
33+
assertEquals("Normal computation 1 Z", expectedNormal.z, normal.z, DELTA);
34+
35+
v1 = new Vec4(-12, 12, 26);
36+
v2 = new Vec4(23, -23, 2);
37+
v3 = new Vec4(13, 13, 13);
38+
expectedNormal = new Vec4(0.4612242682795252, -0.1396190373706287, 0.8762298207398077);
39+
normal = WWMath.computeTriangleNormal(v1, v2, v3);
40+
assertEquals("Normal computation 2 X", expectedNormal.x, normal.x, DELTA);
41+
assertEquals("Normal computation 2 Y", expectedNormal.y, normal.y, DELTA);
42+
assertEquals("Normal computation 2 Z", expectedNormal.z, normal.z, DELTA);
43+
}
44+
}

0 commit comments

Comments
 (0)