Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	cameraproject/src/geometries/Tube.java
	cameraproject/src/unittests/geometries/TriangleTest.java
	cameraproject/src/unittests/geometries/TubeTest.java
  • Loading branch information
Eliyahu-r authored and Eliyahu-r committed Mar 21, 2021
2 parents 9aeb3be + 1df71d2 commit 23636ae
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cameraproject/src/geometries/Tube.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cameraproject/src/primitives/Ray.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Ray(Point3D p0, Vector dir) {
}

/**
* -----
* Get the head point of the Ray
* @return starting point
*/
public Point3D getP0() {
Expand Down
14 changes: 14 additions & 0 deletions cameraproject/src/unittests/geometries/PlaneTest.java
Original file line number Diff line number Diff line change
@@ -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");
}

}
19 changes: 19 additions & 0 deletions cameraproject/src/unittests/geometries/SphereTest.java
Original file line number Diff line number Diff line change
@@ -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));
}

}
46 changes: 24 additions & 22 deletions cameraproject/src/unittests/geometries/TubeTest.java
Original file line number Diff line number Diff line change
@@ -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));//-------
}

}
2 changes: 1 addition & 1 deletion cameraproject/src/unittests/primitives/VectorTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
* hhhh
*/
package unittests.primitives;

Expand Down

0 comments on commit 23636ae

Please sign in to comment.