Class Int2

java.lang.Object
me.autobot.lib.math.coordinates.Int2

public class Int2 extends Object
A class that represents a 2D integer coordinate.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The properties of the Int2 object, such as flags, identities, etc.
    int
    The x coordinate value of the Int2 object.
    int
    The y coordinate value of the Int2 object.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Int2(int x, int y)
    Creates a new Int2 object with the given x and y values.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Int2 other)
    Returns a new Int2 object that is the sum of this Int2 object and another Int2 object.
    double
    distance(Int2 other)
    Calculates the distance between this Int2 object and another Int2 object.
    double
    Calculates the square of the distance between this Int2 object and another Int2 object.
    boolean
    Checks if this Int2 object is equal to another object via comparing x and y values.
    Finds and gets the Int2 object in a list of Int2 objects that is equal to this Int2 object.
    boolean
    Checks if this Int2 object is in a passed list of Int2 objects.
    Converts this Int2 object to a string.
    Converts this Int2 object to a Vector2d object.
    static Int2
    Creates a blank Int2 object with the values of 0, 0.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • x

      public int x
      The x coordinate value of the Int2 object.
    • y

      public int y
      The y coordinate value of the Int2 object.
    • properties

      public HashMap<String,Object> properties
      The properties of the Int2 object, such as flags, identities, etc.
  • Constructor Details

    • Int2

      public Int2(int x, int y)
      Creates a new Int2 object with the given x and y values.
      Parameters:
      x - The x value of the Int2 object.
      y - The y value of the Int2 object.
  • Method Details

    • zero

      public static Int2 zero()
      Creates a blank Int2 object with the values of 0, 0.
      Returns:
      A new Int2 object with the values of 0, 0.
    • distance

      public double distance(Int2 other)
      Calculates the distance between this Int2 object and another Int2 object.
      Parameters:
      other - The other Int2 object.
      Returns:
      The distance between the two Int2 objects.
    • distancesq

      public double distancesq(Int2 other)
      Calculates the square of the distance between this Int2 object and another Int2 object. Equivalent to hypotenuse^2.
      Parameters:
      other - The other Int2 object.
      Returns:
      The square of the distance between the two Int2 objects.
    • inList

      public boolean inList(ArrayList<Int2> list)
      Checks if this Int2 object is in a passed list of Int2 objects.
      Parameters:
      list - The list of Int2 objects to check.
      Returns:
      True if this Int2 object is in the list, false otherwise.
    • add

      public Int2 add(Int2 other)
      Returns a new Int2 object that is the sum of this Int2 object and another Int2 object.
      Parameters:
      other - The other Int2 object.
      Returns:
      A new Int2 object that is the sum of this Int2 object and the other Int2 object.
    • getInList

      public Int2 getInList(ArrayList<Int2> list)
      Finds and gets the Int2 object in a list of Int2 objects that is equal to this Int2 object.
      Parameters:
      list - The list of Int2 objects to check.
      Returns:
      The Int2 object in the list that is equal to this Int2 object. May be null if not found.
    • toVector2d

      public Vector2d toVector2d()
      Converts this Int2 object to a Vector2d object.
      Returns:
      A new Vector2d object with the same x and y values as this Int2 object.
    • equals

      public boolean equals(Object obj)
      Checks if this Int2 object is equal to another object via comparing x and y values.
      Overrides:
      equals in class Object
      Parameters:
      obj - The other object.
    • toString

      public String toString()
      Converts this Int2 object to a string.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this Int2 object.