-
Notifications
You must be signed in to change notification settings - Fork 2
/
PlaneTest.java
38 lines (30 loc) · 1.17 KB
/
PlaneTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package exercise;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class PlaneTest {
final static double DELTA = 0.00001;
@Test
public void PlaneConstructorTest() {
Plane plane = new Plane(new Vec3D(2, 0, 0), new Vec3D(1, 0, 0));
assertTrue(plane instanceof Geometry);
assertEquals(plane.planePoint, new Vec3D(2, 0, 0));
assertEquals(plane.normal, new Vec3D(1, 0, 0));
}
@Test
public void PlaneIntersectionTest() {
Plane plane = new Plane(new Vec3D(2, 0, 0), new Vec3D(1, 0, 0));
Ray ray = new Ray(new Vec3D(0, 0, 0), new Vec3D(1, 1, 0));
Vec3D intersection = plane.intersect(ray);
assertEquals(intersection.x, 2.0, DELTA);
assertEquals(intersection.y, 2.0, DELTA);
assertEquals(intersection.z, 0.0, DELTA);
}
@Test
public void PlaneNoIntersectionTest() {
Plane plane = new Plane(new Vec3D(2, 0, 0), new Vec3D(1, 0, 0));
Ray ray = new Ray(new Vec3D(0, 0, 0), new Vec3D(0, 1, 0));
Vec3D intersection = plane.intersect(ray);
assertEquals(intersection, null);
}
}