Ejemplo n.º 1
0
 // Gets the cross product of the two given vectors
 public Vector getCrossProduct(Vector vec)
 {
     return new Vector(
         y*vec.z-z*vec.y,
         z*vec.x-x*vec.z,
         x*vec.y-y*vec.x
     );
 }
Ejemplo n.º 2
0
        public Plane(Point a, Point b, Point c)
        {
            // Variables
            Vector	ab=	a.subtract(b);
            Vector	ac=	a.subtract(c);

            dir=	ab.getCrossProduct(ac);
            d=	(dir.x*a.x+dir.y*a.y+dir.z*a.z);
        }
Ejemplo n.º 3
0
 public Plane(Point a, Vector v1, Vector v2)
     : this(a, a.add(v1), a.add(v2))
 {
 }
Ejemplo n.º 4
0
 // --- Constructors ---
 public Plane(Vector pmDir, float distance)
 {
     dir=	pmDir;
     d=	distance;
 }
Ejemplo n.º 5
0
 // Gets the dot product of the two given vectors
 public float getDotProduct(Vector vec)
 {
     return (x*vec.x+y*vec.y+z*vec.z);
 }
Ejemplo n.º 6
0
 // --- Methods ---
 // Adds the vector to the given vector
 public Vector add(Vector vec)
 {
     return new Vector(x+vec.x, y+vec.y, z+vec.z);
 }
Ejemplo n.º 7
0
 // Subtracts the vector from the given vector, to make it point towards this vector
 public Vector subtract(Vector vec)
 {
     return new Vector(x-vec.x, y-vec.y, z-vec.z);
 }
Ejemplo n.º 8
0
        // Projects the vector onto the given vector
        public Vector project(Vector vecB)
        {
            // Variables
            float	scalar=	getDotProduct(vecB);

            scalar/=	getMagnitudeSq();

            return vecB.multiply(scalar);
        }
Ejemplo n.º 9
0
 // --- Constructors ---
 // <x, y, z> = <x0, y0, z0> + t<a, b, c>
 public Line(Point pmInitPos, Vector pmDir)
 {
     initPos=	pmInitPos;
     dir=	pmDir;
 }
Ejemplo n.º 10
0
 // Subtracts the given vector with the point to get a new point
 public Point subtract(Vector vec)
 {
     return new Point(x-vec.x, y-vec.y, z-vec.z);
 }
Ejemplo n.º 11
0
 // --- Methods ---
 // Adds the given vector with the point to get a new point
 public Point add(Vector vec)
 {
     return new Point(x+vec.x, y+vec.y, z+vec.z);
 }