# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

2 Pages

### Plane

Course: CS 390, Spring 2010
School: Westminster UT
Rating:

Word Count: 229

#### Document Preview

raytracer.geometricObjects; package import raytracer.utility.*; public class Plane extends GeometricObject { private Point3D a; private Normal n; rays // point through which plane passes // normal to the plane // for shadows and secondary private static final double kEpsilon = 0.001; // ---------------------------------------------------------------------default constructor public Plane() { super(); a = new...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Utah >> Westminster UT >> CS 390

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
raytracer.geometricObjects; package import raytracer.utility.*; public class Plane extends GeometricObject { private Point3D a; private Normal n; rays // point through which plane passes // normal to the plane // for shadows and secondary private static final double kEpsilon = 0.001; // ---------------------------------------------------------------------default constructor public Plane() { super(); a = new Point3D(0.0); n = new Normal(0, 1, 0); } // ---------------------------------------------------------------------constructor public Plane(Point3D point, Normal normal) { super(); a = new Point3D(point); n = new Normal(normal); n.normalize(); } // ---------------------------------------------------------------- copy constructor public Plane(Plane plane) { super(plane); a = new Point3D(plane.a); n = new Normal(plane.n); } // ---------------------------------------------------------------- clone public GeometricObject clone() { return (new Plane(this)); // } ---------------------------------------------------------------assignment operator public void set (Plane rhs) if (this != rhs) { super.set(rhs); a.set(rhs.a); n.set(rhs.n); } } // ----------------------------------------------------------------- hit { // // // // textbook has it return a boolean we altered it here so it returns tmin hit returns a -1 if no hit hit returns a number > 0 if hit public double hit(Ray ray, ShadeRec sr) { double t = ((a.subtract(ray.o)).dot(n)) / ((ray.d.dot(n))); if (t > kEpsilon) { sr.normal = n; sr.local_hit_point = ray.o.add(ray.d.multiply(t)); } } public boolean equals(Object obj) { if (obj == null || this.getClass() != obj.getClass()) { return false; } else { Plane other = (Plane)obj; return (super.equals(obj) && a.equals(other.a) && n.equals(other.n)); } } public String toString() { return color + "plane through " + a + " with " + n; } } return t; return -1;
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Westminster UT - CS - 390
package raytracer.geometricObjects; import raytracer.utility.*; public class Sphere extends GeometricObject cfw_ private Point3D center; / center coordinates as a point private double radius; / the radius private static final double kEpsilon = 0.001; / fo
Westminster UT - CS - 390
package raytracer.geometricObjects; import raytracer.utility.*; /this is the triangle discussed in Section 19.3 public class Triangle extends GeometricObject cfw_ private Point3D v0, v1, v2; private Normal normal; / -constructor public Triangle()cfw_ supe
Westminster UT - CS - 390
package raytracer.tracers; import raytracer.utility.*; import raytracer.world.World; public class MultipleObjects extends Tracer cfw_ / -default constructor public MultipleObjects() cfw_ super(); / -constructor public MultipleObjects(World world) cfw_ su
Westminster UT - CS - 390
package raytracer.tracers; import raytracer.utility.*; import raytracer.world.World; public class SingleSphere extends Tracer cfw_ / -default constructor public SingleSphere() cfw_ super(); / -constructor public SingleSphere(World world)cfw_ super(world)
Westminster UT - CS - 390
package raytracer.tracers; import raytracer.utility.Ray; import raytracer.utility.RGBColor; import raytracer.world.World; /This is the declaration of the base class Tracer /The tracer classes have no copy constructor, assignment operator. or clone functio
Westminster UT - CS - 390
package raytracer.utility; public class public public public public Constants cfw_ static final static final static final static final double double double double TWO_PI PI_ON_180 invPI invTWO_PI = = = = Math.PI*2.; Math.PI/180.; 1./Math.PI; 0.5*Math.PI;
Westminster UT - CS - 390
package raytracer.utility; /* * this file contains the declaration of the class Matrix * Matrix is a 4 x 4 square matrix that is used to represent affine transformations * we don't need a general m x n matrix * */ public class Matrix cfw_ public double[][
Westminster UT - CS - 390
package raytracer.utility; import java.util.Vector; import raytracer.geometricObjects.MeshTriangle; /* * / / / /Copyright (C) Kevin Suffern 2000-2007. This C+ code is for non-commercial purposes only. This C+ code is licensed under the GNU General Public
Westminster UT - CS - 390
package raytracer.utility; public class Normal cfw_ public double x, y, z;/ - default constructor public Normal() cfw_ x = y = z = 0; / - constructor public Normal(double a) cfw_ x = y = z = a; / - constructor public Normal(double a, double b, double c
Westminster UT - CS - 390
package raytracer.utility; /2D points are used to store sample points public class Point2D cfw_ public float x, y; / - default constructor public Point2D() cfw_ x = 0.f; y = 0.f; / - constructor public Point2D(float arg)cfw_ x = arg; y = arg; / - constr
Westminster UT - CS - 390
package raytracer.utility; public class Point3D cfw_ public double x, y, z; / - default constructor public Point3D()cfw_ x = y = z = 0; / - constructor public Point3D(double a)cfw_ x = y = z = a; / - constructor public Point3D(double a, double b, double
Westminster UT - CS - 390
package raytracer.utility; public class Ray cfw_ public Point3D public Vector3D o; d; / origin / direction/ - default constructor public Ray () cfw_ o = new Point3D(0.0); d = new Vector3D(0.0, 0.0, 1.0); / -constructor public Ray (Point3D origin, Vector
Westminster UT - CS - 390
package raytracer.utility; public class public public public public RGBColor cfw_ float r, g, b; static final RGBColor black = new RGBColor(0f); static final RGBColor white = new RGBColor(1f); static final RGBColor red = new RGBColor(1.0f, 0.0f, 0.0f);/
Westminster UT - CS - 390
package raytracer.utility; import raytracer.world.World; /There is no default constructor as the World reference has to be initialised /There is also no assignment operator as we don't want to assign the world anywhere /The copy constructor only copies th
Westminster UT - CS - 390
package raytracer.utility; public class Vector3D cfw_ public double x, y, z; / - default constructor public Vector3D() cfw_ x = y = z = 0.0; / - constructor public Vector3D(double a) cfw_ x = y = z = a; / - constructor public Vector3D(double a, double b
Westminster UT - CS - 390
package raytracer.world; /import raytracer.utility.Normal; public class ViewPlane cfw_ public int image resolution public int resolution public float size public int samples per pixel public float correction factor public float the gamma correction factor
Westminster UT - CS - 390
package raytracer.world; import raytracer.utility.*; import raytracer.geometricObjects.*; import raytracer.tracers.*; import raytracer.cameras.Camera; import raytracer.cameras.Pinhole; import java.util.Vector; import java.awt.*; /This file contains the de
Westminster UT - CS - 390
/ This file contains the definition the ViewPlane class # #include &quot;ViewPlane.h&quot; / - default constructor V ViewPlane:ViewPlane(void) : hres(400), vres(400), s(1.0), gamma(1.0), inv_gamma(1.0), show_out_of_gamut(false) cfw_ cfw_ / - copy constructor ViewPl
Westminster UT - CS - 390
#ifndef _VIEW_PLANE_ # #define _VIEW_PLANE_ /- class ViewPlane class ViewPlane cfw_ public: int image resolution int resolution float size float correction factor float the gamma correction factor bool RGBColor out of gamuthres; vres; s; gamma; inv_gamma
Westminster UT - CS - 390
/ this file contains the definition of the World class # #include &quot;wxraytracer.h&quot; #include &quot;World.h&quot; # #include &quot;Constants.h&quot; / / geometric objects #include &quot;Plane.h&quot; # #include &quot;Sphere.h&quot; / / tracers #include &quot;SingleSphere.h&quot; # #include &quot;MultipleObjects.
Westminster UT - CS - 390
#ifndef _WORLD_ # #define _WORLD_ / This file contains the declaration of the class World / The World class does not have a copy constructor or an assignment operator, for the followign reasons: / 1 There's no need to copy construct or assign the World /
Westminster UT - CS - 390
#ifndef _CONSTANTS_ # #define _CONSTANTS_ #include &lt;stdlib.h&gt; # #include &quot;RGBColor.h&quot; const const const const const double double double double double PI TWO_PI PI_ON_180 invPI invTWO_PI kEpsilon kHugeValue = 3.1415926535897932384; = 6.2831853071795864769
Westminster UT - CS - 390
#ifndef _MATHS_ # #define _MATHS_ inline double m max(double x0, double x1); inline double max(double x0, double x1) cfw_ return(x0 &gt; x1) ? x0 : x1); #endif
Westminster UT - CS - 390
/ This file contains the definition of the class Matrix # #include &quot;Matrix.h&quot; / - default constructor / / a default matrix is an identity matrix M Matrix:Matrix(void) cfw_ for (int x = 0; x &lt; 4; x+) for (int y = 0; y &lt; 4; y+) cfw_ if (x = y) m[x][y] = 1.0
Westminster UT - CS - 390
#ifndef _MATRIX_ # #define _MATRIX_ / this file contains the declaration of the class Matrix / Matrix is a 4 x 4 square matrix that is used to represent affine transformations / / we don't need a general m x n matrix / /- class Matrix c class Matrix cfw_
Westminster UT - CS - 390
/ This file contains the defintion of the class Normal # #include &lt;math.h&gt; # #include &quot;Normal.h&quot; / / - default constructor Normal:Normal(void) : x(0.0), y(0.0), z(0.0) cfw_ / / - constructor Normal:Normal(double a) : x(a), y(a), z(a) cfw_ / / - constructo
Westminster UT - CS - 390
#ifndef _NORMAL_ # #define _NORMAL_ / / This file contains the declaration of the class Normal #include &quot;Matrix.h&quot; #include &quot;Vector3D.h&quot; # #include &quot;Point3D.h&quot; class Normal cfw_ p public: double p public: Normal(void); / default constructor Normal(double
Westminster UT - CS - 390
/ this file contains the definition of the class Point3D #include &lt;math.h&gt; # #include &quot;Point3D.h&quot; / / - default constructor Point3D:Point3D() :x(0), y(0), z(0) cfw_ cfw_ / / - constructor Point3D:Point3D(const double a) :x(a), y(a), z(a) cfw_ cfw_ / / - c
Westminster UT - CS - 390
#ifndef _POINT3D_ # #define _POINT3D_ / / This file contains the defintion of the class Point3D #include &quot;Matrix.h&quot; # #include &quot;Vector3D.h&quot; class Point3D cfw_ p public: d double x, y, z; Point3D(); / default constructor Point3D(const double a); / construc
Westminster UT - CS - 390
#include &quot;Ray.h&quot; / - default constructor Ray:Ray (void) : o(0.0), d(0.0, 0.0, 1.0) cfw_ / / - constructor Ray:Ray (const Point3D&amp; origin, const Vector3D&amp; dir) : o(origin), d(dir) cfw_ / - copy constructor Ray:Ray (const Ray&amp; ray) : o(ray.o), d(ray.d) cfw_
Westminster UT - CS - 390
#ifndef _RAY_ # #define _RAY_ #include &quot;Point3D.h&quot; # #include &quot;Vector3D.h&quot; class Ray cfw_ p public: Point3D Vector3D R Ray(void); R Ray(const Point3D&amp; origin, const Vector3D&amp; dir); R Ray(const Ray&amp; ray); R Ray&amp; operator= (const Ray&amp; rhs); ~Ray(void); ; #
Westminster UT - CS - 390
/ This file contains the definition of the class RGBColor # #include &lt;math.h&gt; # #include &quot;RGBColor.h&quot; / / - default constructor RGBColor:RGBColor(void) : r(0.0), g(0.0), b(0.0) cfw_ cfw_ / / - constructor RGBColor:RGBColor(float c) : r(c), g(c), b(c) cfw_
Westminster UT - CS - 390
#ifndef _RGB_COLOR_ # #define _RGB_COLOR_ / / This file contains the declaration of the class RGBColor / /- class RGBColor c class RGBColor cfw_ p public: float r, g, b; r p public: RGBColor(void); / default constructor RGBColor(float c); / constructor RG
Westminster UT - CS - 390
/ this file contains the definition of the class ShadeRec / there is no default constructor as the World reference always has to be initialised / there is also no assignment operator as we don't want to assign the world / the copy constructor only copies
Westminster UT - CS - 390
#ifndef _SHADE_REC_ # #define _SHADE_REC_ / / this file contains the declaration of the class ShadeRec class World; is a reference / only need a forward class declaration as the World data member#include &quot;Point3D.h&quot; #include &quot;Normal.h&quot; # #include &quot;RGBCol
Westminster UT - CS - 390
/ This file contains the definition of the class Vector3D # #include &lt;math.h&gt; #include &quot;Vector3D.h&quot; #include &quot;Normal.h&quot; # #include &quot;Point3D.h&quot; / / - default constructor Vector3D:Vector3D(void) : x(0.0), y(0.0), z(0.0) cfw_ / / - constructor Vector3D:Vecto
Westminster UT - CS - 390
#ifndef _VECTOR_3D_ # #define _VECTOR_3D_ / / This file contains the defintion of the class Vector3D # #include &quot;Matrix.h&quot; class Normal; c class Point3D; / /- class Vector3D class Vector3D cfw_ p public: double p public: Vector3D(void); / default construc
Westminster UT - CS - 390
Westminster UT - CS - 390
Westminster UT - CS - 390
#include #include #include #include # #include&lt;wx/wx.h&gt; &lt;wx/dcbuffer.h&gt; &quot;wxraytracer.h&quot; &quot;main.xpm&quot; &quot;bg.xpm&quot;/*/ /* wxraytracerapp */ / /*/ BEGIN_EVENT_TABLE(wxraytracerapp, wxApp) E END_EVENT_TABLE() I IMPLEMENT_APP(wxraytracerapp) bool wxraytracerapp:On
Westminster UT - CS - 390
#ifndef _WXRAYTRACER_H_ # #define _WXRAYTRACER_H_ /* * Ray Tracer skeleton * * Author : Sverre Kvaale &lt;sverre@kvaale.com&gt; * Version: 0.8 * */ #include &lt;wx/wx.h&gt; #include &quot;World.h&quot; # #include &lt;vector&gt; u using namespace std; class class class c class wxrayt
Westminster UT - CS - 390
#include &quot;MultipleObjects.h&quot; # #include &quot;World.h&quot; / - default constructor MultipleObjects:MultipleObjects(void) : Tracer() cfw_ cfw_ / / - constructor MultipleObjects:MultipleObjects(World* _worldPtr) : Tracer(_worldPtr) cfw_ cfw_ / / - destructor M Multi
Westminster UT - CS - 390
#ifndef _MULTIPLE_OBJECTS_ # #define _MULTIPLE_OBJECTS_ # #include &quot;Tracer.h&quot; class MultipleObjects: public Tracer cfw_ p public: M MultipleObjects(void); M MultipleObjects(World* _world_ptr); v virtual ~ ~MultipleObjects(void); v virtual RGBColor trace_r
Westminster UT - CS - 390
#include &quot;SingleSphere.h&quot; #include &quot;World.h&quot; # #include &quot;ShadeRec.h&quot; / - default constructor SingleSphere:SingleSphere(void) : Tracer() cfw_ cfw_ / / - constructor SingleSphere:SingleSphere(World* _worldPtr) : Tracer(_worldPtr) cfw_ cfw_ / / - destructor
Westminster UT - CS - 390
#ifndef _SINGLE_SPHERE_ # #define _SINGLE_SPHERE_ # #include &quot;Tracer.h&quot; class SingleSphere: public Tracer cfw_ p public: S SingleSphere(void); S SingleSphere(World* _worldPtr); v virtual ~ ~SingleSphere(void); v virtual RGBColor trace_ray(const Ray&amp; ray)
Westminster UT - CS - 390
#include &quot;Tracer.h&quot; / - default constructor Tracer:Tracer(void) : world_ptr(NULL) cfw_ cfw_ / / - constructor Tracer:Tracer(World* _worldPtr) : world_ptr(_worldPtr) cfw_ cfw_/ / - destructor Tracer:~Tracer(void) cfw_ if (world_ptr) world_ptr = NULL; / /
Westminster UT - CS - 390
/ This is the declaration of the base class Tracer / The tracer classes have no copy constructor, assignment operator. or clone function because / of the world pointer, which should not be assigned or copy constructed / / See comments in the World.h file.
Westminster UT - CS - 390
/ this file contains the definition of the class GeometricObject #include &quot;Constants.h&quot; # #include &quot;GeometricObject.h&quot; / - default constructor GeometricObject:GeometricObject(void) : color(black) cfw_ cfw_ / - copy constructor GeometricObject:GeometricObj
Westminster UT - CS - 390
#ifndef _GEOMETRIC_OBJECT_ # #define _GEOMETRIC_OBJECT_ / / this file contains the declaration of the class GeometricObject #include #include #include #include # #include &quot;RGBColor.h&quot; &quot;Point3D.h&quot; &quot;Normal.h&quot; &quot;Ray.h&quot; &quot;ShadeRec.h&quot;# #include &quot;Constants.h&quot; c
Westminster UT - CS - 390
#include &quot;Plane.h&quot; c const double Plane:kEpsilon = 0.001; / -constructor P Plane:Plane(void) : GeometricObject(), a(0.0), n n(0, 1, 0) cfw_ cfw_ / -constructor Plane:Plane(const Point3D&amp; point, const Normal&amp; normal) : GeometricObject(), a(point), n(normal
Westminster UT - CS - 390
#ifndef _PLANE_ # #define _PLANE_ # #include &quot;GeometricObject.h&quot; / /- class Plane c class Plane: public GeometricObject cfw_ p public: Plane(void); / default constructor constructor Plane(const Point3D&amp; point, const Normal&amp; normal); /Plane(const Plane&amp; p
Westminster UT - CS - 390
/ This file contains the definition of the class sphere #include &quot;Sphere.h&quot; # #include &quot;math.h&quot; c const double Sphere:kEpsilon = 0.001; / - default constructor S Sphere:Sphere(void) : GeometricObject(), center(0.0), radius(1.0) cfw_ cfw_ / / - constructor
Westminster UT - CS - 390
#ifndef _SPHERE_ # #define _SPHERE_ / / This file contains the declaration of the class Sphere # #include &quot;GeometricObject.h&quot; /-class Sphere c class Sphere: public GeometricObject cfw_ public: Sphere(void); Default constructor Sphere(Point3D center, doubl
Westminster UT - CS - 390
/ This builds the cover image for Chapter 3: Bare Bones Ray Tracing v void World:build(void) cfw_ vp.set_hres(400); vp.set_vres(400); v vp.set_pixel_size(0.5); background_color = RGBColor(0.0); t tracer_ptr = new MultipleObjects(this); / / colours RGBColo
Westminster UT - CS - 390
void World:build(void) cfw_ vp.set_hres(200); vp.set_vres(200); v vp.set_pixel_size(1.0); t tracer_ptr = new MultipleObjects(this); b background_color = RGBColor(black); / / use access functions to set centre and radius Sphere* sphere_ptr = new Sphere; sp
Westminster UT - CS - 390
void World:build(void) cfw_ vp.set_hres(200); vp.set_vres(200); vp.set_pixel_size(1.0); v vp.set_gamma(1.0); background_color = white; t tracer_ptr = new SingleSphere(this); sphere.set_center(0.0); sphere.set_radius(85);
Westminster UT - MATH - 1240
4100 AWL/Thomas_ch05p325-395 8/20/04 9:58 AM Page 395Chapter 5Technology Application Projects395Chapter 5Technology Application ProjectsMathematica/Maple ModuleUsing Riemann Sums to Estimate Areas, Volumes, and Lengths of Curves Visualize and appro
Westminster UT - MATH - 1240
4100 AWL/Thomas_ch14p965-1066 8/25/04 2:53 PM Page 984984Chapter 14: Partial Derivatives14.3Partial DerivativesThe calculus of several variables is basically single-variable calculus applied to several variables one at a time. When we hold all but on
University of Texas - GOV - 38655
American Government Test 1 Review Federalist Papers - supported the ratification of the US constitution. - #10 - by James Madison - addresses how to guard against factions with interests opposite of the rights of others or the interest of the whole commun
University of Phoenix - ACC 220 - 90
Internal Cash Control1Week 4 Assignment Internal Cash Control Denise Keith ACC / 220 February 14, 2010 Teri MooreInternal Cash Control2Many companies have issues with their cash handling procedures. They do not know how to track where their cash is g
University of Phoenix - COM 220 - AAGI0H3E26
Annotated Bibliography Battersby, S. (2009). Is Pluto a planet after all? New Scientist Magazine. Retrieved January 29, 2010. from: www.newscientist./com/aricle/mg20327 181.600-is-pluto-a-planet-after-all.html This article offers hope to the many fans of