// 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 ); }
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); }
public Plane(Point a, Vector v1, Vector v2) : this(a, a.add(v1), a.add(v2)) { }
// --- Constructors --- public Plane(Vector pmDir, float distance) { dir= pmDir; d= distance; }
// Gets the dot product of the two given vectors public float getDotProduct(Vector vec) { return (x*vec.x+y*vec.y+z*vec.z); }
// --- 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); }
// 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); }
// Projects the vector onto the given vector public Vector project(Vector vecB) { // Variables float scalar= getDotProduct(vecB); scalar/= getMagnitudeSq(); return vecB.multiply(scalar); }
// --- Constructors --- // <x, y, z> = <x0, y0, z0> + t<a, b, c> public Line(Point pmInitPos, Vector pmDir) { initPos= pmInitPos; dir= pmDir; }
// 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); }
// --- 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); }