Package com.algo.rendering
Class Vector2D
- java.lang.Object
-
- com.algo.rendering.Vector2D
-
- All Implemented Interfaces:
java.io.Serializable
public class Vector2D extends java.lang.Object implements java.io.Serializable
A 2-dimensional immutable vector.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Vector2D
closestPointOnLine(double px, double py, double l1x, double l1y, double l2x, double l2y)
double
diamondLength()
int
dimensions()
static double
distancePointToLine(double px, double py, double l1x, double l1y, double l2x, double l2y)
static double
distancePointToLine(double px, double py, Vector2D a, Vector2D b)
boolean
equals(java.lang.Object obj)
double
get(int dimension)
static Vector2D
getVectorAtAngle(double angle, double length)
Returns a vector for a given angle and length.double
getX()
double
getY()
int
hashCode()
double
length()
double
measureAngleX()
Vector2D
minus(double x, double y)
Vector2D
minus(Vector2D other)
Vector2D
multiply(double c)
double
multiply(Vector2D other)
Vector2D
normalized()
static Vector2D
one()
Vector2D
orthogonal()
Vector2D
orthogonal(int sign)
Vector2D
plus(double x, double y)
Vector2D
plus(Vector2D other)
Vector2D
rotate(double alpha)
Vector2D
rotate(Vector2D reference, double alpha)
Vector2D
snapToGrid(double gridSize)
double
theta()
java.lang.String
toString()
static Vector2D
zero()
-
-
-
Constructor Detail
-
Vector2D
public Vector2D(double x, double y)
-
Vector2D
public Vector2D(Vector2D v)
-
-
Method Detail
-
getVectorAtAngle
public static Vector2D getVectorAtAngle(double angle, double length)
Returns a vector for a given angle and length. Angle in degrees
-
closestPointOnLine
public static Vector2D closestPointOnLine(double px, double py, double l1x, double l1y, double l2x, double l2y)
-
distancePointToLine
public static double distancePointToLine(double px, double py, double l1x, double l1y, double l2x, double l2y)
-
distancePointToLine
public static double distancePointToLine(double px, double py, Vector2D a, Vector2D b)
-
zero
public static Vector2D zero()
-
one
public static Vector2D one()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getX
public double getX()
-
getY
public double getY()
-
get
public double get(int dimension)
-
dimensions
public int dimensions()
-
orthogonal
public Vector2D orthogonal()
-
orthogonal
public Vector2D orthogonal(int sign)
-
plus
public Vector2D plus(double x, double y)
-
minus
public Vector2D minus(double x, double y)
-
multiply
public double multiply(Vector2D other)
-
normalized
public Vector2D normalized()
-
multiply
public Vector2D multiply(double c)
-
rotate
public Vector2D rotate(double alpha)
-
length
public double length()
-
diamondLength
public double diamondLength()
-
theta
public double theta()
-
snapToGrid
public Vector2D snapToGrid(double gridSize)
-
measureAngleX
public double measureAngleX()
- Returns:
- X Angle in degrees
-
-