Package snap.geom
Class Vect
java.lang.Object
snap.geom.Vect
- All Implemented Interfaces:
Cloneable
This class represents a vector.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the given vector to this.clone()
Standard clone implementation.static double
getAngleBetween
(double aX, double aY, double bX, double bY) Returns the angle between vectors (using given vector points).double
getAngleBetween
(Vect aVect) Returns the angle between the receiver and the given vector.static double
getDotProduct
(double aX, double aY, double bX, double bY) Returns the dot product of two vectors.double
getDotProduct
(Vect v2) Returns the dot product of the receiver and the given vector.double
Returns the magnitude of the vector.static double
getMagnitude
(double aX, double aY) Returns the magnitude of a vector.static double
getProjectedDistance
(double aX, double aY, double bX, double bY) Returns the length of V1 as projected onto V2 (using given vector 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.void
Makes the vector unit length.void
setXY
(double aX, double aY) Sets the X/Y values.void
Sets the X/Y values.toString()
Returns a string representation of the vector.void
Transforms this vector by the given transform.
-
Field Details
-
x
public double x -
y
public double y
-
-
Constructor Details
-
Vect
public Vect()Constructor. -
Vect
public Vect(double aX, double aY) Constructor for given XY coords.
-
-
Method Details
-
getMagnitude
public double getMagnitude()Returns the magnitude of the vector. -
normalize
public void normalize()Makes the vector unit length. -
add
Add the given vector to this. -
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. -
negate
public void negate()Makes this receiver point in the opposite direction. -
transform
Transforms this vector by the given transform. -
setXY
Sets the X/Y values. -
setXY
public void setXY(double aX, double aY) Sets the X/Y values. -
clone
Standard clone implementation. -
toString
Returns a string representation of the vector. -
getMagnitude
public static double getMagnitude(double aX, double aY) Returns the magnitude of a vector. -
getDotProduct
public static double getDotProduct(double aX, double aY, double bX, double bY) Returns the dot product of two vectors. -
getAngleBetween
public static double getAngleBetween(double aX, double aY, double bX, double bY) Returns the angle between vectors (using given vector points). -
getProjectedDistance
public static double getProjectedDistance(double aX, double aY, double bX, double bY) Returns the length of V1 as projected onto V2 (using given vector points).
-