Package snap.gfx3d
Class Vector3D
java.lang.Object
snap.gfx3d.Vector3D
- All Implemented Interfaces:
Cloneable
This class represents a 3D vector.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the given vector to this.clone()
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
Standard equals implementation.double
getAngleBetween
(Vector3D aVector) 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
Returns whether given vector is in same general direction of this (with option to include perpendiculars).boolean
Returns whether given vector is pointing away from the direction of this (with option to include perpendiculars).void
negate()
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
setVectorBetweenPoints
(Point3D p0, Point3D p1) Constructor for vector from given point to second given point.toString()
Standard toString implementation.
-
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
Creates a new vector from the given vector. -
Vector3D
Constructor for vector from given point to second given point.
-
-
Method Details
-
getMagnitude
public double getMagnitude()Returns the magnitude of the vector. -
normalize
Makes the vector unit length. -
add
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
Returns the vector perpendicular to the receiver and the given vector. -
getDotProduct
Returns the dot product of the receiver and the given vector. -
isAligned
Returns whether given vector is in same general direction of this (with option to include perpendiculars). -
isAway
Returns whether given vector is pointing away from the direction of this (with option to include perpendiculars). -
getAngleBetween
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
Constructor for vector from given point to second given point. -
clone
Standard clone implementation. -
equals
Standard equals implementation. -
toString
Standard toString implementation. -
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
Returns the normal of given points. See Path3D.getNormal(). -
getNormalForPoints3fv
Returns the normal of given points. See Path3D.getNormal().
-