public interface Vector
Vector
s.
This interface does not specify any particular unit of length to be used. Implementations are expected to have some sort of internal plane coordinate system (like a single UTM zone) which all coordinate values and vectors refer to. Angular units are defined to be the natural unit (radians).
Modifier and Type | Field and Description |
---|---|
static double |
FULL_CIRCLE
2 π is the angle of a full circle (in radians; equal to 360°).
|
static double |
RIGHT_ANGLE
½ π is a right angle (in radians; equal to 90°).
|
static double |
SEMI_CIRCLE
π is the angle of a semi-circle (in radians; equal to 180°).
|
Modifier and Type | Method and Description |
---|---|
Vector |
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.
|
double |
distance()
The vector's length (norm).
|
double |
easting()
The ordinate (horizontal / longitudinal) aspect of the vector's
coordinate representation.
|
boolean |
isAligned(Vector v)
Compares this vector's bearing to the specified vector's bearing.
|
double |
northing()
The abscissa (vertical / latitudinal) aspect of the vector's
coordinate representation.
|
double |
relativeBearing(Vector v)
The angle from this vector's direction to the specified vector's
direction, measured counterclockwise or clockwise, whichever is nearer.
|
Vector |
reversed()
Returns a reversed representation of this vector.
|
static final double FULL_CIRCLE
static final double SEMI_CIRCLE
static final double RIGHT_ANGLE
double easting()
double northing()
double distance()
double bearing()
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.
SimpleVector.normaliseAbsoluteBearing(double)
,
Bearing (Wikipedia)double relativeBearing(Vector v)
java.lang.Math
.
For example, if this vector pointed to the south and the specified vector pointed east, this method would return −½ π (equal to −90°).
It is strongly recommended for implementations to return bearings normalised to the interval [−π, π), but clients should not depend upon this behaviour.
v
- the vector to calculate the bearing of in relation to this
vector+0.0
must be returnedNullPointerException
- iff v == null
SimpleVector.normaliseRelativeBearing(double)
,
Relative bearing (Wikipedia)Vector reversed()
Vector aligned(Vector v)
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.v
- the vector to be compared with this onev
NullPointerException
- iff v == null
isAligned(de.thaw.comb.util.Vector)
boolean isAligned(Vector v)
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;
v
- the vector to be compared with this oneNullPointerException
- iff v == null
.relativeBearing(de.thaw.comb.util.Vector)