diff --git a/cameraproject/src/geometries/Tube.java b/cameraproject/src/geometries/Tube.java index 9e9c48a..fd191a8 100644 --- a/cameraproject/src/geometries/Tube.java +++ b/cameraproject/src/geometries/Tube.java @@ -40,7 +40,7 @@ public double getRadius() { public Vector getNormal(Point3D point) { double t = axisRay.getDir().dotProduct(point.subtract(axisRay.getP0())); Point3D o = axisRay.getP0().add(axisRay.getDir().scale(t)); - return o.subtract(point).normalized(); + return point.subtract(o).normalized(); } /** diff --git a/cameraproject/src/primitives/Ray.java b/cameraproject/src/primitives/Ray.java index 852909c..e2b6b74 100644 --- a/cameraproject/src/primitives/Ray.java +++ b/cameraproject/src/primitives/Ray.java @@ -20,7 +20,7 @@ public Ray(Point3D p0, Vector dir) { } /** - * ----- + * Get the head point of the Ray * @return starting point */ public Point3D getP0() { diff --git a/cameraproject/src/unittests/geometries/PlaneTest.java b/cameraproject/src/unittests/geometries/PlaneTest.java new file mode 100644 index 0000000..f212b21 --- /dev/null +++ b/cameraproject/src/unittests/geometries/PlaneTest.java @@ -0,0 +1,14 @@ +package unittests.geometries; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class PlaneTest { + + @Test + public void testGetNormalPoint3D() { + fail("Not yet implemented"); + } + +} diff --git a/cameraproject/src/unittests/geometries/SphereTest.java b/cameraproject/src/unittests/geometries/SphereTest.java new file mode 100644 index 0000000..d90584f --- /dev/null +++ b/cameraproject/src/unittests/geometries/SphereTest.java @@ -0,0 +1,19 @@ +package unittests.geometries; + +import static org.junit.Assert.*; +import geometries.*; +import primitives.*; + +import org.junit.Test; + +public class SphereTest { + + @Test + public void testGetNormal() { + Sphere s = new Sphere(new Point3D(1,1,1), 2); + + // ============ Equivalence Partitions Tests ============== + assertEquals("",s.getNormal(new Point3D(1,1,3)),new Vector(0,0,1)); + } + +} diff --git a/cameraproject/src/unittests/geometries/TubeTest.java b/cameraproject/src/unittests/geometries/TubeTest.java index 5d4c30c..92aa5cc 100644 --- a/cameraproject/src/unittests/geometries/TubeTest.java +++ b/cameraproject/src/unittests/geometries/TubeTest.java @@ -1,22 +1,24 @@ -package unittests.geometries; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import geometries.Tube; -import primitives.Point3D; -import primitives.Ray; -import primitives.Vector; - -public class TubeTest { - - @Test - public void testGetNormal() { - Tube tube = new Tube(new Ray(new Point3D(0, 0, 2), new Vector(new Point3D(0, 0, 1))), 2); - - // ============ Equivalence Partitions Tests ============== - assertEquals("",tube.getNormal(new Point3D(0,2,0)),new Vector(0,-1,0)); - } - -} +package unittests.geometries; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import geometries.Tube; +import primitives.Point3D; +import primitives.Ray; +import primitives.Vector; + +public class TubeTest { + + @Test + public void testGetNormal() { + Tube tube = new Tube(new Ray(new Point3D(0, 0, 2), new Vector(new Point3D(0, 0, 1))), 2); + + // ============ Equivalence Partitions Tests ============== + assertEquals("",tube.getNormal(new Point3D(0,2,0)),new Vector(0,1,0)); + + assertEquals("",tube.getNormal(new Point3D(0,2,2)),new Vector(0,1,0));//------- + } + +} diff --git a/cameraproject/src/unittests/primitives/VectorTest.java b/cameraproject/src/unittests/primitives/VectorTest.java index 036d25d..662c586 100644 --- a/cameraproject/src/unittests/primitives/VectorTest.java +++ b/cameraproject/src/unittests/primitives/VectorTest.java @@ -1,5 +1,5 @@ /** - * + * hhhh */ package unittests.primitives;