Class Vector3D


  • public final class Vector3D
    extends java.lang.Object
    The Vector3D class implements a three dimensional vector (components x, y, z) with its standard operations: addition and multiplication (scalar, dot-product, cross-product). It is used to represent planar lines and planar points which are represented by three dimensional planes and three dimensional lines through the origin, respectively.
    • Field Detail

      • x

        public double x
        the x-coordinate of this Vector3D.
      • y

        public double y
        the y-coordinate of this Vector3D.
      • z

        public double z
        the homogeneous coordinate of this Vector3D.
    • Constructor Detail

      • Vector3D

        public Vector3D​(double px,
                        double py,
                        double pz)
        Constructs a new Vector3D object with the given component values.
        Parameters:
        px - The x-coordinate of the new Vector3D.
        py - The y-coordinate of the new Vector3D.
        pz - The z-coordinate of the new Vector3D.
      • Vector3D

        public Vector3D​(Point p)
        Constructs a new Vector3D from the given Point, setting z to 1.
        Parameters:
        p - The Point which determines the new Vector3D's x- and y-coordinate.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • getCrossProduct

        public Vector3D getCrossProduct​(Vector3D other)
        Returns a new Vector3D object that is the cross product of this and the given other Vector3D.
        Parameters:
        other - The Vector3D to which the cross product is computed.
        Returns:
        a new Vector3D object that is the cross product of this and the given other Vector3D
      • getDotProduct

        public double getDotProduct​(Vector3D other)
        Returns the dot-product of this and the given other Vector3D.
        Parameters:
        other - The Vector3D to which the dot product is computed.
        Returns:
        the dot-product of this and the given other Vector3D
      • getRatio

        public Vector3D getRatio​(Vector3D other,
                                 double t)
        Returns a new Vector3D object with its components set to the given ratio between this Vector3D and the given other Vector3D.
        Parameters:
        other - The other Vector3D.
        t - The ratio.
        Returns:
        a new Vector3D object with its components set to the given ratio between this Vector3D and the given other Vector3D
      • getScaled

        public Vector3D getScaled​(double f)
        Returns a new Vector3D object with its components set to the x, y and z components of this Vector3D scaled by the given factor.
        Parameters:
        f - The scaling factor.
        Returns:
        a new Vector3D object with its components set to the x, y and z components of this Vector3D scaled by the given factor
      • getSubtracted

        public Vector3D getSubtracted​(Vector3D other)
        Returns a new Vector3D object with its components set to the difference of the individual x, y and z components of this Vector3D and the given other Vector3D.
        Parameters:
        other - The Vector3D which is subtracted from this Vector3D.
        Returns:
        a new Vector3D object representing the difference of this Vector3D and the given other Vector3D
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toPoint

        public Point toPoint()
        Returns a new Point object that is represented by this Vector3D.
        Returns:
        a new Point object that is represented by this Vector3D
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object