Package me.autobot.lib.math.coordinates
Class Int2
java.lang.Object
me.autobot.lib.math.coordinates.Int2
A class that represents a 2D integer coordinate.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a new Int2 object that is the sum of this Int2 object and another Int2 object.double
Calculates the distance between this Int2 object and another Int2 object.double
distancesq
(Int2 other) 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.toString()
Converts this Int2 object to a string.Converts this Int2 object to a Vector2d object.static Int2
zero()
Creates a blank Int2 object with the values of 0, 0.
-
Field Details
-
x
public int xThe x coordinate value of the Int2 object. -
y
public int yThe y coordinate value of the Int2 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
Creates a blank Int2 object with the values of 0, 0.- Returns:
- A new Int2 object with the values of 0, 0.
-
distance
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
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
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
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
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
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
Checks if this Int2 object is equal to another object via comparing x and y values. -
toString
Converts this Int2 object to a string.
-