Class MapVec

java.lang.Object
com.massifmaps.core.MapVec

public class MapVec extends Object
A double precision map vector defined by 3 coordinates.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a MapVec object.
    MapVec(double x, double y)
    Constructs a MapVec object from 2 coordinates.
    MapVec(double x, double y, double z)
    Constructs a MapVec object from 3 coordinates.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new map vector by adding a map vector to this map vector.
    double
    Calculates 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.
    double
    Calculates the dot product between this and another map vector.
    boolean
    Checks if this object is equal to the specified object.
    Creates a new map vector by normalizing this map vector.
    double
    Returns the x coordinate of this map vector.
    double
    Returns the y coordinate of this map vector.
    double
    Returns the z coordinate of this map vector.
    int
    Returns the hash value of this object.
    double
    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.
    Creates a string representation of this map vector, useful for logging.

    Methods inherited from class java.lang.Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • 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

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      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

      public MapVec add(MapVec v)
      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

      public MapVec sub(MapVec v)
      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

      public MapVec mul(double multiplier)
      Creates a new map vector by multiplying this map vector with a multiplier.
      Parameters:
      multiplier - The multiplier.
      Returns:
      The new map vector.
    • div

      public MapVec div(double divider)
      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

      public MapVec getNormalized()
      Creates a new map vector by normalizing this map vector.
      Returns:
      The new normalized map vector.
    • crossProduct2D

      public double crossProduct2D(MapVec v)
      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

      public MapVec crossProduct3D(MapVec v)
      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

      public double dotProduct(MapVec v)
      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

      public String toString()
      Creates a string representation of this map vector, useful for logging.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this map vector.