예제 #1
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Find the normalized version of the given vector.
  * @param <Vector> v
  * @return <Vector>
  */
 public static Vector Norm(Vector v)
 {
     double mag = Mag(v);
     double div = mag == 0 ? double.PositiveInfinity : 1 / mag;
     return Scale(v,div);
 }
예제 #2
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Find the magnitude of the given vector.
  * @param <Vector> v
  * @return <double>
  */
 public static double Mag(Vector v)
 {
     return Math.Sqrt(Dot(v, v));
 }
예제 #3
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Subtract one vector from another.
  * @param <Vector> v1
  * @param <Vector> v2
  * @return <Vector>
  */
 public static Vector Minus(Vector v1, Vector v2)
 {
     return new Vector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
 }
예제 #4
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Find the dot-product of two vectors.
  * @param <Vector> v1
  * @param <Vector> v2
  * @return <double>
  */
 public static double Dot(Vector v1, Vector v2)
 {
     return (v1.X * v2.X) + (v1.Y * v2.Y) + (v1.Z * v2.Z);
 }
예제 #5
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Determine if two vectors are equivalent.
  * @param <Vector> v1
  * @param <Vector> v2
  * @return <bool>
  */
 public static bool Equals(Vector v1, Vector v2)
 {
     return (v1.X == v2.X) && (v1.Y == v2.Y) && (v1.Z == v2.Z);
 }
예제 #6
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Find the cross product of two vectors.
  * @param <Vector> v1
  * @param <Vector> v2
  * @return <Vector>
  */
 public static Vector Cross(Vector v1, Vector v2)
 {
     return new Vector(((v1.Y * v2.Z) - (v1.Z * v2.Y)), ((v1.Z * v2.X) - (v1.X * v2.Z)), ((v1.X * v2.Y) - (v1.Y * v2.X)));
 }
예제 #7
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Scale a vector
  * @param <Vector> v
  * @param <double> x
  * @return <Vector>
  */
 public static Vector Scale(Vector v, double x)
 {
     return new Vector(v.X *x, v.Y*x,v.Z*x);
 }
예제 #8
0
파일: Vector.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Add two vectors together.
  * @param <Vector> v1
  * @param <Vector> v2
  * @return <Vector>
  */
 public static Vector Plus(Vector v1, Vector v2)
 {
     return new Vector(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
 }
예제 #9
0
파일: Sphere.cs 프로젝트: sreiff/Ray-Tracer
 /**
  * Find the normal vector of the sphere at the given position.
  * @param <Vector> pos
  * @return <Vector>
  */
 public override Vector Normal(Vector pos)
 {
     return Vector.Norm(Vector.Minus(pos, Center));
 }
예제 #10
0
 public abstract Vector Normal(Vector pos);