public final class Vector2d extends Object implements Serializable
Constructor and Description |
---|
Vector2d() |
Vector2d(double x,
double y) |
Modifier and Type | Method and Description |
---|---|
double |
angleWith(Vector2d v)
Returns the conical (unsigned) angle between this vector and vector v.
|
double |
azimuthAngle() |
double |
cosAngleWith(Vector2d v)
Returns cosine of the angle between this vector and vector v.
|
static Vector2d |
createPolar(double radius,
double theta)
Create Vector2d from polar coordinates.
|
static Vector2d |
createPolarTranslated(double radius,
double theta,
double translateX,
double translateY)
Create Vector2d from polar coordinates with given translation of origin.
|
double |
distance(Vector2d v) |
double |
distanceSquared(Vector2d v) |
double |
dotProduct(Vector2d v) |
boolean |
equals(Object o) |
String |
format(String coordFormat)
Get formatted String representation.
|
static Vector2d |
fromArray(double[] coords) |
double |
getX() |
double |
getY() |
int |
hashCode() |
boolean |
isZero() |
static Vector2d |
linearCombination(double[] a,
Vector2d[] w) |
static Vector2d |
linearCombination(double a1,
Vector2d v1,
double a2,
Vector2d v2) |
Vector2d |
minus(Vector2d v) |
double |
norm() |
Vector2d |
normalized()
Returns normalized (rescaled to norm = 1) version of this vector.
|
Vector2d |
normalizedLenient()
Returns normalized (rescaled to norm = 1) version of this vector.
|
double |
normSquared() |
Vector2d |
perpendicularVector()
Returns a vector perpendicular to this one, with same norm.
|
Vector2d |
plus(Vector2d v) |
Vector2d |
projectionOnto(Vector2d v,
boolean isLenient)
Returns the projection of this vector onto the vector v.
|
Vector2d |
projectOnto(Vector2d v)
Returns the projection of this vector onto the vector v.
|
Vector2d |
rotatedAboutOriginBy(double theta) |
Vector2d |
scalarProduct(double alpha) |
Vector2d |
scaledBy(double scaleFactor) |
double[] |
toArray() |
String |
toString() |
Vector3d |
toVector3d(double z)
Concatenate z component to form ThreeVector.
|
public double getX()
public double getY()
public String format(String coordFormat)
coordFormat
- format applied to each coordinate (as in String.format)public Vector2d scalarProduct(double alpha)
public Vector2d scaledBy(double scaleFactor)
public double dotProduct(Vector2d v)
public double azimuthAngle()
public double normSquared()
public double norm()
public boolean isZero()
public Vector2d normalized()
Note: "Strict" version: if zero vector, returned vector will contain all NaN values and a warning will be logged.
public Vector2d normalizedLenient()
Note: "Lenient" version: If zero vector, returned vector will be (1, 0).
public double distanceSquared(Vector2d v)
public double distance(Vector2d v)
public double cosAngleWith(Vector2d v)
public double angleWith(Vector2d v)
public Vector2d projectOnto(Vector2d v)
for lenient handling of v
public Vector2d projectionOnto(Vector2d v, boolean isLenient)
public Vector2d rotatedAboutOriginBy(double theta)
theta
- rotation anglepublic Vector2d perpendicularVector()
public Vector3d toVector3d(double z)
z
- public double[] toArray()
public static Vector2d fromArray(double[] coords)
public static Vector2d createPolar(double radius, double theta)
radius
- distance from center (0,0)theta
- azimuth anglepublic static Vector2d createPolarTranslated(double radius, double theta, double translateX, double translateY)
radius
- distance from center (translateX, translateY)theta
- azimuth angletranslateX
- translateY
- public static Vector2d linearCombination(double a1, Vector2d v1, double a2, Vector2d v2)
Copyright © 2013 Metron, Inc.. All rights reserved.