public final class SimpleVector extends Object implements Vector
FULL_CIRCLE, RIGHT_ANGLE, SEMI_CIRCLE
Constructor and Description |
---|
SimpleVector(PlaneCoordinates start,
PlaneCoordinates end)
Creates a vector from
start to end . |
Modifier and Type | Method and Description |
---|---|
SimpleVector |
aligned(Vector v)
Compares this vector to the specified vector with regards to their
convergence.
|
double |
bearing()
The angle from grid north to the vector's direction, measured clockwise.
|
(package private) static SimpleVector |
createFromDistanceBearing(double distance,
double bearing)
Creates a vector given in polar coordinates.
|
double |
distance()
The vector's length (norm).
|
static double |
distance(PlaneCoordinates point1,
PlaneCoordinates point2)
Obtain the distance (in internal coordinates) between two points.
|
double |
easting()
The ordinate (horizontal / longitudinal) aspect of the vector's
coordinate representation.
|
static double |
eastingFromDistanceBearing(double distance,
double bearing)
Obtain the distance in the ordinate (horizontal / longitudinal) aspect
of a vector given in polar coordinates.
|
boolean |
isAligned(Vector v)
Compares this vector's bearing to the specified vector's bearing.
|
static double |
normaliseAbsoluteBearing(double bearing)
Reduces a bearing to the interval [0, 2 π).
|
static double |
normaliseRelativeBearing(double bearing)
Reduces a bearing to the interval [−π, π).
|
double |
northing()
The abscissa (vertical / latitudinal) aspect of the vector's
coordinate representation.
|
static double |
northingFromDistanceBearing(double distance,
double bearing)
Obtain the distance in the abscissa (vertical / latitudinal) aspect of
a vector given in polar coordinates.
|
double |
relativeBearing(Vector v)
The angle from this vector's direction to the specified vector's
direction, measured counterclockwise or clockwise, whichever is nearer.
|
SimpleVector |
reversed()
Returns a reversed representation of this vector.
|
String |
toString()
Returns a string representation of this object.
|
public SimpleVector(PlaneCoordinates start, PlaneCoordinates end)
start
to end
.start
- the initial pointend
- the terminal pointNullPointerException
- iff start == null || end == null
static SimpleVector createFromDistanceBearing(double distance, double bearing)
distance
- the lengthbearing
- the directionNullPointerException
- iff start == null || end == null
Vector.bearing()
public double easting()
Vector
public double northing()
Vector
public static double distance(PlaneCoordinates point1, PlaneCoordinates point2)
point1
and point2
NullPointerException
- iff point1 == null || point2 == null
public double distance()
Vector
public double bearing()
Vector
Math
.
For example, if a vector pointed to the west, this method would return 3/2 π (equal to 270°).
It is strongly recommended for implementations to return bearings normalised to the interval [0, 2 π), but clients should not depend upon this behaviour.
bearing
in interface Vector
normaliseAbsoluteBearing(double)
,
Bearing (Wikipedia)public double relativeBearing(Vector v)
relativeBearing
in interface Vector
v
- the vector to calculate the bearing of in relation to this
vector0.0
if v
is zero-lengthnormaliseRelativeBearing(double)
,
Relative bearing (Wikipedia)public static double normaliseAbsoluteBearing(double bearing)
==
for congruency.bearing
- the bearing to normalisebearing
, normalisedpublic static double normaliseRelativeBearing(double bearing)
==
for congruency.bearing
- the bearing to normalisebearing
, normalisedpublic SimpleVector reversed()
Vector
public SimpleVector aligned(Vector v)
Vector
return isAligned(v) ? clone() : reversed();
If the vectors already are aligned, implementations are free to return
either this
itself or another Vector
object of
equivalent value, at their option.aligned
in interface Vector
v
- the vector to be compared with this onev
Vector.isAligned(de.thaw.comb.util.Vector)
public boolean isAligned(Vector v)
Vector
Implementations might use code that basically produces the same result
as the following line does:
The result of this method if the vectors are orthogonal is undefined.
return Math.abs( relativeBearing(v) ) < RIGHT_ANGLE;
isAligned
in interface Vector
v
- the vector to be compared with this oneVector.relativeBearing(de.thaw.comb.util.Vector)
public String toString()
public static double eastingFromDistanceBearing(double distance, double bearing)
easting()
of a vector created from the polar coordinates, but
this method forgoes creating a new object for this purpose.distance
- the lengthbearing
- the directionpublic static double northingFromDistanceBearing(double distance, double bearing)
northing()
of a vector created from the polar coordinates, but
this method forgoes creating a new object for this purpose.distance
- the lengthbearing
- the direction