Package snap.gfx3d

Class Vector3D

java.lang.Object
snap.gfx3d.Vector3D
All Implemented Interfaces:
Cloneable

public class Vector3D extends Object implements Cloneable
This class represents a 3D vector.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
     
    double
     
    double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
    Vector3D(double x, double y, double z)
    Constructor for the given vector components.
    Constructor for vector from given point to second given point.
    Vector3D(Vector3D aVector)
    Creates a new vector from the given vector.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Vector3D aVector)
    Add the given vector to this.
    Standard clone implementation.
    static boolean
    equals(double v0x, double v0y, double v0z, double v1x, double v1y, double v1z)
    Returns whether given vector components are equal.
    boolean
    equals(Object anObj)
    Standard equals implementation.
    double
    Returns the angle between the receiver and the given vector.
    Returns the vector perpendicular to the receiver and the given vector.
    double
    Returns the dot product of the receiver and the given vector.
    double
    Returns the magnitude of the vector.
    static Vector3D
    getNormalForPoints(Vector3D aVect, Point3D... thePoints)
    Returns the normal of given points.
    static Vector3D
    getNormalForPoints3fv(Vector3D aVect, float[] pointsArray, int pointCount)
    Returns the normal of given points.
    boolean
    isAligned(Vector3D aVector, boolean includePerpendiculars)
    Returns whether given vector is in same general direction of this (with option to include perpendiculars).
    boolean
    isAway(Vector3D aVector, boolean includePerpendiculars)
    Returns whether given vector is pointing away from the direction of this (with option to include perpendiculars).
    void
    Makes this receiver point in the opposite direction.
    Makes the vector unit length.
    void
    scale(double aScale)
    Scales this vector by given factor.
    void
    setVector(double aX, double aY, double aZ)
    Constructor for vector from given point to second given point.
    void
    Constructor for vector from given point to second given point.
    Standard toString implementation.

    Methods inherited from class java.lang.Object

    finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • x

      public double x
    • y

      public double y
    • z

      public double z
  • Constructor Details

    • Vector3D

      public Vector3D()
      Constructor.
    • Vector3D

      public Vector3D(double x, double y, double z)
      Constructor for the given vector components.
    • Vector3D

      public Vector3D(Vector3D aVector)
      Creates a new vector from the given vector.
    • Vector3D

      public Vector3D(Point3D p0, Point3D p1)
      Constructor for vector from given point to second given point.
  • Method Details

    • getMagnitude

      public double getMagnitude()
      Returns the magnitude of the vector.
    • normalize

      public Vector3D normalize()
      Makes the vector unit length.
    • add

      public void add(Vector3D aVector)
      Add the given vector to this.
    • scale

      public void scale(double aScale)
      Scales this vector by given factor.
    • negate

      public void negate()
      Makes this receiver point in the opposite direction.
    • getCrossProduct

      public Vector3D getCrossProduct(Vector3D v2)
      Returns the vector perpendicular to the receiver and the given vector.
    • getDotProduct

      public double getDotProduct(Vector3D v2)
      Returns the dot product of the receiver and the given vector.
    • isAligned

      public boolean isAligned(Vector3D aVector, boolean includePerpendiculars)
      Returns whether given vector is in same general direction of this (with option to include perpendiculars).
    • isAway

      public boolean isAway(Vector3D aVector, boolean includePerpendiculars)
      Returns whether given vector is pointing away from the direction of this (with option to include perpendiculars).
    • getAngleBetween

      public double getAngleBetween(Vector3D aVector)
      Returns the angle between the receiver and the given vector.
    • setVector

      public void setVector(double aX, double aY, double aZ)
      Constructor for vector from given point to second given point.
    • setVectorBetweenPoints

      public void setVectorBetweenPoints(Point3D p0, Point3D p1)
      Constructor for vector from given point to second given point.
    • clone

      public Vector3D clone()
      Standard clone implementation.
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object
    • equals

      public static boolean equals(double v0x, double v0y, double v0z, double v1x, double v1y, double v1z)
      Returns whether given vector components are equal.
    • getNormalForPoints

      public static Vector3D getNormalForPoints(Vector3D aVect, Point3D... thePoints)
      Returns the normal of given points. See Path3D.getNormal().
    • getNormalForPoints3fv

      public static Vector3D getNormalForPoints3fv(Vector3D aVect, float[] pointsArray, int pointCount)
      Returns the normal of given points. See Path3D.getNormal().