Class Vector3D

java.lang.Object
org.eclipse.gef.geometry.projective.Vector3D

public final class Vector3D extends 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 Details

    • 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 Details

    • 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 Details

    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • getAdded

      public Vector3D getAdded(Vector3D other)
      Returns a new Vector3D object with its components set to the sum of the individual x, y and z components of this Vector3D and the given other Vector3D.
      Parameters:
      other - The Vector3D which is added to this Vector3D.
      Returns:
      a new Vector3D object representing the sum of this Vector3D and the given other Vector3D
    • getCopy

      public Vector3D getCopy()
      Returns a copy of this Vector3D.
      Returns:
      a copy of this Vector3D
    • 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 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 String toString()
      Overrides:
      toString in class Object