public class

MapVec

extends Object
java.lang.Object
   ↳ com.carto.core.MapVec

Class Overview

A double precision map vector defined by 3 coordinates.

Summary

Public Constructors
MapVec()
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.
Public Methods
MapVec add(MapVec v)
Creates a new map vector by adding a map vector to this map vector.
double crossProduct2D(MapVec v)
Calculates the 2D cross product between this and another map vector.
MapVec crossProduct3D(MapVec v)
Creates a new map vector that's perpendicular to the plane defined by this and another map vector.
synchronized void delete()
MapVec div(double divider)
Creates a new map vector by dividing this map vector with a divider.
double dotProduct(MapVec v)
Calculates the dot product between this and another map vector.
boolean equals(Object obj)
Checks if this object is equal to the specified object.
MapVec getNormalized()
Creates a new map vector by normalizing this map vector.
double getX()
Returns the x coordinate of this map vector.
double getY()
Returns the y coordinate of this map vector.
double getZ()
Returns the z coordinate of this map vector.
int hashCode()
Returns the hash value of this object.
double length()
Calculates the length of this map vector.
MapVec mul(double multiplier)
Creates a new map vector by multiplying this map vector with a multiplier.
MapVec sub(MapVec v)
Creates a new map vector by subtracting a map vector from this map vector.
String toString()
Creates a string representation of this map vector, useful for logging.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public MapVec ()

Constructs a MapVec object. All coordinates will be 0.

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.

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.

Public Methods

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.

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.

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.

public synchronized void delete ()

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.

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.

public boolean equals (Object obj)

Checks if this object is equal to the specified object.

Parameters
obj The reference object.
Returns
  • True when objects are equal, false otherwise.

public MapVec getNormalized ()

Creates a new map vector by normalizing this map vector.

Returns
  • The new normalized map vector.

public double getX ()

Returns the x coordinate of this map vector.

Returns
  • The x coordinate of this map vector.

public double getY ()

Returns the y coordinate of this map vector.

Returns
  • The y coordinate of this map vector.

public double getZ ()

Returns the z coordinate of this map vector.

Returns
  • The z coordinate of this map vector.

public int hashCode ()

Returns the hash value of this object.

Returns
  • The hash value of this object.

public double length ()

Calculates the length of this map vector.

Returns
  • The length of this map vector.

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.

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.

public String toString ()

Creates a string representation of this map vector, useful for logging.

Returns
  • The string representation of this map vector.