Class V3D_Vector

java.lang.Object
uk.ac.leeds.ccg.v3d.core.V3D_Object
uk.ac.leeds.ccg.v3d.geometry.V3D_Vector
All Implemented Interfaces:
java.io.Serializable

public class V3D_Vector
extends V3D_Object
V3D_Vector
Version:
1.0
Author:
Andy Turner
See Also:
Serialized Form
  • Field Details

    • dx

      public final ch.obermuhlner.math.big.BigRational dx
      The change in x.
    • dy

      public final ch.obermuhlner.math.big.BigRational dy
      The change in y.
    • dz

      public final ch.obermuhlner.math.big.BigRational dz
      The change in z.
    • magnitude

      public java.math.BigDecimal magnitude
      For storing the magnitude.
  • Constructor Details

    • V3D_Vector

      public V3D_Vector​(V3D_Environment e, ch.obermuhlner.math.big.BigRational dx, ch.obermuhlner.math.big.BigRational dy, ch.obermuhlner.math.big.BigRational dz)
      Parameters:
      e - V3D_Environment
      dx - What dx is set to.
      dy - What dy is set to.
      dz - What dz is set to.
    • V3D_Vector

      public V3D_Vector​(V3D_Point p)
      Creates a vector from the origin to p
      Parameters:
      p - the point to which the vector starting at the origin goes.
    • V3D_Vector

      public V3D_Vector​(V3D_Point p, V3D_Point q)
      Creates a vector from p to q
      Parameters:
      p - the point where the vector starts.
      q - the point where the vector ends.
  • Method Details

    • toString

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

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

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

      public boolean isZeroVector()
      Returns:
      true if this.equals(e.zeroVector)
    • multiply

      public V3D_Vector multiply​(ch.obermuhlner.math.big.BigRational s)
      Parameters:
      s - The scalar value to multiply this by.
      Returns:
      Scaled vector.
    • add

      public V3D_Vector add​(V3D_Vector v)
      Parameters:
      v - The vector to add.
      Returns:
      A new vector which is this add v.
    • subtract

      public V3D_Vector subtract​(V3D_Vector v)
      Parameters:
      v - The vector to subtract.
      Returns:
      A new vector which is this subtract v.
    • getDotProduct

      public ch.obermuhlner.math.big.BigRational getDotProduct​(V3D_Vector v)
      Calculate and return the dot product.
      Parameters:
      v - V3D_Vector
      Returns:
      dot product
    • isOrthogonal

      public boolean isOrthogonal​(V3D_Vector v)
      Test if this is orthogonal to v.
      Parameters:
      v - The
      Returns:
      true if this and v are orthogonal.
    • getMagnitude

      public java.math.BigDecimal getMagnitude​(int scale, java.math.RoundingMode rm)
      Get the magnitude of the vector at the given scale.
      Parameters:
      scale - The scale for the precision of the result.
      rm - The RoundingMode for any rounding.
      Returns:
      magnitude initialised with scale and rm.
    • initMagnitude

      protected java.math.BigDecimal initMagnitude​(int scale, java.math.RoundingMode rm)
      Parameters:
      scale - The scale for the precision of the result.
      rm - The RoundingMode for any rounding.
      Returns:
      magnitude initialised with scale and rm.
    • isParallel

      public boolean isParallel​(V3D_Vector v)
      Test if this is parallel to v.
      Parameters:
      v - The vector to test if it is parallel to this.
      Returns:
      true if this and v are orthogonal.
    • getCrossProduct

      public V3D_Vector getCrossProduct​(V3D_Vector v)
      Calculate and return the cross product. Treat this as the first vector and v as the second vector. The resulting vector is in the direction given by the right hand rule.
      Parameters:
      v - V3D_Vector
      Returns:
      V3D_Vector
    • getUnitVector

      public V3D_Vector getUnitVector​(int scale, java.math.RoundingMode rm)
      Scales the vector by the magnitude so that it has length 1
      Parameters:
      scale - The scale for the precision of the result.
      rm - The RoundingMode for any rounding.
      Returns:
      this scaled by the magnitude.