Package com.massifmaps.core
Class MapVec
java.lang.Object
com.massifmaps.core.MapVec
A double precision map vector defined by 3 coordinates.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new map vector by adding a map vector to this map vector.doubleCalculates the 2D cross product between this and another map vector.Creates a new map vector that's perpendicular to the plane defined by this and another map vector.div(double divider) Creates a new map vector by dividing this map vector with a divider.doubledotProduct(MapVec v) Calculates the dot product between this and another map vector.booleanChecks if this object is equal to the specified object.Creates a new map vector by normalizing this map vector.doublegetX()Returns the x coordinate of this map vector.doublegetY()Returns the y coordinate of this map vector.doublegetZ()Returns the z coordinate of this map vector.inthashCode()Returns the hash value of this object.doublelength()Calculates the length of this map vector.mul(double multiplier) Creates a new map vector by multiplying this map vector with a multiplier.Creates a new map vector by subtracting a map vector from this map vector.toString()Creates a string representation of this map vector, useful for logging.
-
Constructor Details
-
MapVec
public MapVec()Constructs a MapVec object. All coordinates will be 0. -
MapVec
public MapVec(double x, double y) Constructs a MapVec object from 2 coordinates. The z coordinate will be 0.- Parameters:
x- The x coordinate.y- The y coordinate.
-
MapVec
public MapVec(double x, double y, double z) Constructs a MapVec object from 3 coordinates.- Parameters:
x- The x coordinate.y- The y coordinate.z- The z coordinate.
-
-
Method Details
-
equals
Checks if this object is equal to the specified object. -
hashCode
public int hashCode()Returns the hash value of this object. -
getX
public double getX()Returns the x coordinate of this map vector.- Returns:
- The x coordinate of this map vector.
-
getY
public double getY()Returns the y coordinate of this map vector.- Returns:
- The y coordinate of this map vector.
-
getZ
public double getZ()Returns the z coordinate of this map vector.- Returns:
- The z coordinate of this map vector.
-
add
Creates a new map vector by adding a map vector to this map vector.- Parameters:
v- The map vector to be added.- Returns:
- The new map vector.
-
sub
Creates a new map vector by subtracting a map vector from this map vector.- Parameters:
v- The map vector to be subtracted.- Returns:
- The new map vector.
-
mul
Creates a new map vector by multiplying this map vector with a multiplier.- Parameters:
multiplier- The multiplier.- Returns:
- The new map vector.
-
div
Creates a new map vector by dividing this map vector with a divider.- Parameters:
divider- The divider.- Returns:
- The new map vector.
-
length
public double length()Calculates the length of this map vector.- Returns:
- The length of this map vector.
-
getNormalized
Creates a new map vector by normalizing this map vector.- Returns:
- The new normalized map vector.
-
crossProduct2D
Calculates the 2D cross product between this and another map vector. Defined as x1 * y2 - y1 * x2.- Parameters:
v- The other map vector.- Returns:
- The 2D cross product between this and another map vector.
-
crossProduct3D
Creates a new map vector that's perpendicular to the plane defined by this and another map vector.- Parameters:
v- The other map vector.- Returns:
- The new perpendicular map vector.
-
dotProduct
Calculates the dot product between this and another map vector.- Parameters:
v- The other map vector.- Returns:
- The dot product between this and another map vector.
-
toString
Creates a string representation of this map vector, useful for logging.
-