Package edu.cnu.mdi.util
Class Point2DSupport
java.lang.Object
edu.cnu.mdi.util.Point2DSupport
Static operations on two-dimensional points interpreted as vectors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleangle(Point2D.Double wp) Get the polar coordinate angle.static doubleangleBetween(Point2D.Double v1, Point2D.Double v2) Get the angle between two vectorsstatic doubleazimuth(Point2D.Double wp0, Point2D.Double wp1) Computes the azimuth from this world point to another.static doublecross(Point2D.Double v1, Point2D.Double v2) Get the magnitude of the cross product.static doubledistance(Point2D.Double wp0, Point2D.Double wp1) Get the distance between two world points.static doubledot(Point2D.Double v1, Point2D.Double v2) Usual inner productstatic doublelength(Point2D.Double wp) The length of the vectorstatic doubleThe length squared of the vector.static Point2D.DoublepointDelta(Point2D.Double wp1, Point2D.Double wp2) This is creation by subtraction.static Point2D.DoubleProject one vector onto another vectorstatic StringGet a string representation.static Point2D.DoubleObtain a unit vector in the same direction as this vector
-
Method Details
-
pointDelta
This is creation by subtraction. Be very careful of the order. This return wp2 - wp1- Parameters:
wp1- the first pointwp2- the second point- Returns:
- the delta, wp2-wp1
-
length
The length of the vector- Parameters:
wp- the point in question- Returns:
- the usual vector magnitude
-
lengthSquare
The length squared of the vector. This can be usefor for faster sorting.- Parameters:
wp- the point in question- Returns:
- the square of the usual vector magnitude
-
unitVector
Obtain a unit vector in the same direction as this vector- Parameters:
wp- the point in question- Returns:
- a unit vector in the same direction as this vector
-
dot
Usual inner product- Parameters:
v1- one vectorv2- another vector- Returns:
- the dot product
-
cross
Get the magnitude of the cross product. The sign tells us whether we are in +z or -z direction.- Parameters:
v1- one vectorv2- another vector- Returns:
- the magnitude of the cross product
-
angleBetween
Get the angle between two vectors- Parameters:
v1- one vectorv2- another vector- Returns:
- the angle between the vectors in degrees.
-
project
Project one vector onto another vector- Parameters:
v- the vector being projecteda- the vector defining the projection direction.- Returns:
- the result of projecting v in the direction of a.
-
angle
Get the polar coordinate angle.- Parameters:
wp- vector to inspect- Returns:
- the angle, in degrees, measured ccw from the x axis.
-
distance
Get the distance between two world points.- Parameters:
wp0- the first world point.wp1- the second world point.- Returns:
- the distance between the two world points.
-
azimuth
Computes the azimuth from this world point to another. The azimuth is the angle, in degrees, measured clockwise from north (the positive y axis) to the line connecting the two points.Unlike a normalized compass bearing, the result is not restricted to
[0, 360)— it is derived directly fromMath.atan2(double, double)and can be negative (e.g. a westward vector returns-90, not270). Callers that need a normalized[0, 360)sweep should useAngleSupport.ccwSweepDeg(java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Double)or equivalent instead.- Parameters:
wp0- the starting world point.wp1- the ending world point.- Returns:
- the azimuth from wp0 to wp1, in degrees; not normalized to
[0, 360)
-
toString
Get a string representation.- Parameters:
wp- point to format- Returns:
- a string representation.
-