Class Vector2d

java.lang.Object
org.spongepowered.math.vector.Vector2d
All Implemented Interfaces:
Serializable, Comparable<Vector2d>, Vectord

@Immutable public final class Vector2d extends Object implements Vectord, Comparable<Vector2d>, Serializable
See Also:
  • Field Details

    • ZERO

      public static final Vector2d ZERO
    • UNIT_X

      public static final Vector2d UNIT_X
    • UNIT_Y

      public static final Vector2d UNIT_Y
    • ONE

      public static final Vector2d ONE
  • Constructor Details

    • Vector2d

      public Vector2d(Vector3d v)
    • Vector2d

      public Vector2d(Vector4d v)
    • Vector2d

      public Vector2d(VectorNd v)
    • Vector2d

      public Vector2d(float x, float y)
    • Vector2d

      public Vector2d(double x, double y)
  • Method Details

    • x

      public double x()
    • withX

      public Vector2d withX(double x)
    • withX

      public Vector2d withX(float x)
    • y

      public double y()
    • withY

      public Vector2d withY(double y)
    • withY

      public Vector2d withY(float y)
    • floorX

      public int floorX()
    • floorY

      public int floorY()
    • add

      public Vector2d add(Vector2d v)
    • add

      public Vector2d add(float x, float y)
    • add

      public Vector2d add(double x, double y)
    • sub

      public Vector2d sub(Vector2d v)
    • sub

      public Vector2d sub(float x, float y)
    • sub

      public Vector2d sub(double x, double y)
    • mul

      public Vector2d mul(float a)
    • mul

      public Vector2d mul(double a)
      Specified by:
      mul in interface Vectord
    • mul

      public Vector2d mul(Vector2d v)
    • mul

      public Vector2d mul(float x, float y)
    • mul

      public Vector2d mul(double x, double y)
    • div

      public Vector2d div(float a)
    • div

      public Vector2d div(double a)
      Specified by:
      div in interface Vectord
    • div

      public Vector2d div(Vector2d v)
    • div

      public Vector2d div(float x, float y)
    • div

      public Vector2d div(double x, double y)
    • dot

      public double dot(Vector2d v)
    • dot

      public double dot(float x, float y)
    • dot

      public double dot(double x, double y)
    • project

      public Vector2d project(Vector2d v)
    • project

      public Vector2d project(float x, float y)
    • project

      public Vector2d project(double x, double y)
    • pow

      public Vector2d pow(float pow)
    • pow

      public Vector2d pow(double power)
      Specified by:
      pow in interface Vectord
    • ceil

      public Vector2d ceil()
      Specified by:
      ceil in interface Vectord
    • floor

      public Vector2d floor()
      Specified by:
      floor in interface Vectord
    • round

      public Vector2d round()
      Specified by:
      round in interface Vectord
    • abs

      public Vector2d abs()
      Specified by:
      abs in interface Vectord
    • negate

      public Vector2d negate()
      Specified by:
      negate in interface Vectord
    • min

      public Vector2d min(Vector2d v)
    • min

      public Vector2d min(float x, float y)
    • min

      public Vector2d min(double x, double y)
    • max

      public Vector2d max(Vector2d v)
    • max

      public Vector2d max(float x, float y)
    • max

      public Vector2d max(double x, double y)
    • distanceSquared

      public double distanceSquared(Vector2d v)
    • distanceSquared

      public double distanceSquared(float x, float y)
    • distanceSquared

      public double distanceSquared(double x, double y)
    • distance

      public double distance(Vector2d v)
    • distance

      public double distance(float x, float y)
    • distance

      public double distance(double x, double y)
    • lengthSquared

      public double lengthSquared()
      Specified by:
      lengthSquared in interface Vectord
    • length

      public double length()
      Specified by:
      length in interface Vectord
    • normalize

      public Vector2d normalize()
      Specified by:
      normalize in interface Vectord
    • minAxis

      public int minAxis()
      Return the axis with the minimal value.
      Specified by:
      minAxis in interface Vectord
      Returns:
      int axis with minimal value
    • maxAxis

      public int maxAxis()
      Return the axis with the maximum value.
      Specified by:
      maxAxis in interface Vectord
      Returns:
      int axis with maximum value
    • toVector3

      public Vector3d toVector3()
    • toVector3

      public Vector3d toVector3(float z)
    • toVector3

      public Vector3d toVector3(double z)
    • toVector4

      public Vector4d toVector4()
    • toVector4

      public Vector4d toVector4(float z, float w)
    • toVector4

      public Vector4d toVector4(double z, double w)
    • toVectorN

      public VectorNd toVectorN()
    • toArray

      public double[] toArray()
      Specified by:
      toArray in interface Vectord
    • toInt

      public Vector2i toInt()
      Specified by:
      toInt in interface Vectord
    • toLong

      public Vector2l toLong()
      Specified by:
      toLong in interface Vectord
    • toFloat

      public Vector2f toFloat()
      Specified by:
      toFloat in interface Vectord
    • toDouble

      public Vector2d toDouble()
      Specified by:
      toDouble in interface Vectord
    • compareTo

      public int compareTo(Vector2d v)
      Specified by:
      compareTo in interface Comparable<Vector2d>
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • from

      public static Vector2d from(double n)
    • from

      public static Vector2d from(double x, double y)
    • createRandomDirection

      public static Vector2d createRandomDirection(Random random)
      Gets the direction vector of a random angle using the random specified.
      Parameters:
      random - to use
      Returns:
      the random direction vector
    • createDirectionDeg

      public static Vector2d createDirectionDeg(float angle)
      Gets the direction vector of a certain angle in degrees.
      Parameters:
      angle - in degrees
      Returns:
      the direction vector
    • createDirectionDeg

      public static Vector2d createDirectionDeg(double angle)
      Gets the direction vector of a certain angle in degrees.
      Parameters:
      angle - in degrees
      Returns:
      the direction vector
    • createDirectionRad

      public static Vector2d createDirectionRad(float angle)
      Gets the direction vector of a certain angle in radians.
      Parameters:
      angle - in radians
      Returns:
      the direction vector
    • createDirectionRad

      public static Vector2d createDirectionRad(double angle)
      Gets the direction vector of a certain angle in radians.
      Parameters:
      angle - in radians
      Returns:
      the direction vector