Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
nevcohen committed Apr 26, 2021
1 parent 55cdc87 commit 89ec1cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
10 changes: 5 additions & 5 deletions cameraproject/src/elements/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public Vector getvRight() {
/**
* Defining the length and width of the view plane (builder design template)
*
* @param width of the view plane (Greater than zero)
* @param width of the view plane (Greater than zero)
* @param height of the view plane (Greater than zero)
* @return the camera itself
* @return the camera itself
*/
public Camera setViewPlaneSize(double width, double height) {
if (width < 0 || isZero(width) || height < 0 && isZero(height))
Expand All @@ -112,7 +112,7 @@ public Camera setViewPlaneSize(double width, double height) {
* Defines the distance of the view plane from the camera
*
* @param distance of the view plane from the camera (Greater than zero)
* @return the camera itself
* @return the camera itself
*/
public Camera setViewPlaneDistance(double distance) {
if (distance < 0 || isZero(distance))
Expand All @@ -126,8 +126,8 @@ public Camera setViewPlaneDistance(double distance) {
*
* @param nX - Number of columns in the view plane
* @param nY - Number of rows in the view plane
* @param j - The column number of the pixel
* @param i - The row number of the pixel
* @param j - The column number of the pixel
* @param i - The row number of the pixel
* @return Ray from the camera through the desired pixel
*/
public Ray constructRayThroughPixel(int nX, int nY, int j, int i) {
Expand Down
19 changes: 10 additions & 9 deletions cameraproject/src/unittests/elements/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ public void testPlane() {
Camera camera = new Camera(new Point3D(0, 0, 0), new Vector(0, 0, -1), new Vector(0, 1, 0));
camera.setViewPlaneSize(3, 3);
camera.setViewPlaneDistance(1);

// TC01: Plane is parallel to the view plane
Plane plane = new Plane(new Point3D(2, 0, -1), new Vector(0,0,-1));
assertEquals("plane, paralell to the view plane, wrong number of intersection points", 9, getSumIntersections(camera, plane));

// TC02: Plane has angles that allow for 9 points
Plane plane = new Plane(new Point3D(2, 0, -1), new Vector(0, 0, -1));
assertEquals("plane, paralell to the view plane, wrong number of intersection points", 9,
getSumIntersections(camera, plane));

// TC02: Plane has angles that allow for 9 points
plane = new Plane(new Point3D(0, 0, -3), new Vector(0, 0.5, -1));
assertEquals("plane, paralell to the view plane, wrong number of intersection points", 9,
getSumIntersections(camera, plane));
// TC03: Plane has a 90 degree angle with ray
getSumIntersections(camera, plane));

// TC03: Plane has a 90 degree angle with ray
plane = new Plane(new Point3D(0, 0, -3), new Vector(0, 1, -1));
assertEquals("plane, paralell to the view plane, wrong number of intersection points", 6,
getSumIntersections(camera, plane));
Expand All @@ -103,7 +104,7 @@ public void testTriangle() {
Camera camera = new Camera(new Point3D(0, 0, 0), new Vector(0, 0, -1), new Vector(0, 1, 0));
camera.setViewPlaneSize(3, 3);
camera.setViewPlaneDistance(1);

// TC01: small triangle is in range of 1 vector
Triangle triangle = new Triangle(new Point3D(0, 1, -2), new Point3D(1, -1, -2), new Point3D(-1, -1, -2));
assertEquals("triangle, is small, creating one point, wrong number of intersection points", 1,
Expand Down

0 comments on commit 89ec1cb

Please sign in to comment.