public final class Vect
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static Vect |
X_HAT
A unit vector in the positive x direction
|
static Vect |
Y_HAT
A unit vector in the positive y direction
|
static Vect |
ZERO
A Vect with zero length
|
| Constructor and Description |
|---|
Vect(Angle angle) |
Vect(Angle angle,
double length) |
Vect(double x,
double y)
Constructs a new vector in Cartesian space with coordinates (x,y).
|
Vect(java.awt.geom.Point2D p) |
| Modifier and Type | Method and Description |
|---|---|
Angle |
angle() |
double |
distanceSquared(Vect b) |
double |
dot(Vect b) |
boolean |
equals(java.lang.Object o) |
boolean |
equals(Vect v) |
int |
hashCode() |
double |
length() |
Vect |
minus(Vect b) |
Vect |
neg() |
Vect |
plus(Vect b) |
Vect |
projectOn(Vect b)
Returns the projection of this onto
b![]() |
Vect |
rotateBy(Angle a) |
Vect |
times(double amt) |
java.awt.geom.Point2D.Double |
toPoint2D() |
java.lang.String |
toString() |
Vect |
unitSize() |
double |
x() |
double |
y() |
public static final Vect ZERO
public static final Vect X_HAT
public static final Vect Y_HAT
public Vect(Angle angle)
angle - ; requires that angle is not null
Constructs a new unit vector in the direction of angle.public Vect(Angle angle, double length)
angle - ; requires that angle is not null
Constructs a new vector in the direction of angle
with length length.public Vect(double x,
double y)
public Vect(java.awt.geom.Point2D p)
p - ; requires that p is not null
Constructs a new vector in Cartesian space located at the
coordinates specified by ppublic Angle angle()
this in polar coordinatespublic double length()
thispublic double x()
this
in Cartesian coordinatespublic double y()
this
in Cartesian coordinatespublic double distanceSquared(Vect b)
b - vect of the d^2 to be computed; requires that b is not nullthis and bpublic Vect plus(Vect b)
b - vector to add to; requires that b is not nullthis and bpublic Vect minus(Vect b)
b - vect to subtract from; requires that b is not nullthis and
bpublic Vect rotateBy(Angle a)
a - angle to rotate by; requires that a is not nullthis
having been rotated around the origin by a.public Vect neg()
this
being rotated by pi radians.public Vect times(double amt)
this scaled
by amt.public Vect projectOn(Vect b)
b
b - vect to project on; requires that b is not nullthis onto
b. The resulting vector has the same angle as
b, but its length is such that this -
c is perpendicular to c.public Vect unitSize()
thispublic double dot(Vect b)
b - vect to take dot product of; requires that
b is not nullthis and
b.public java.awt.geom.Point2D.Double toPoint2D()
Point2D object which is
located at the same point as this.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(Vect v)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object