Package com.marcpg.libpg.storing
Record Class Cord
java.lang.Object
java.lang.Record
com.marcpg.libpg.storing.Cord
- Record Components:
x
- The X value as a double.y
- The Y value as a double.z
- The Z value as a double.
- All Implemented Interfaces:
Serializable
Represents a simple coordinate with only X, Y, and Z values.
- See Also:
-
Constructor Summary
ConstructorDescriptionCord
(double x, double y, double z) Creates an instance of aCord
record class. -
Method Summary
Modifier and TypeMethodDescription@NotNull Cord
Adds the input cord to this cord.Converts two corners, so one has the lowest x, y and z and one has the highest x, y and z.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.boolean
inBounds
(double lowX, double highX, double lowY, double highY, double lowZ, double highZ) Checks if thisCord
lays inside the specified bounds.boolean
Checks if this cord lays inside the specified bounds.static @NotNull Cord
Converts a list of three objects, X, Y, and Z, into a Cord.@NotNull Cord
rotated()
Swaps the x and z values of this coordinate.final String
toString()
Returns a string representation of this record class.double
x()
Returns the value of thex
record component.double
y()
Returns the value of they
record component.double
z()
Returns the value of thez
record component.
-
Constructor Details
-
Method Details
-
add
Adds the input cord to this cord. Does not affect this object and creates a new one for the result.- Parameters:
cord
- The second addend of this addition.- Returns:
- The sum/total of this addition as a new Cord.
-
rotated
Swaps the x and z values of this coordinate. Does not affect this object and creates a new one for the result.- Returns:
- The swapped values as a new Cord.
-
inBounds
Checks if this cord lays inside the specified bounds.- Parameters:
lowCord
- The bound's corner containing the lowest X, Y, and Z.highCord
- The bound's corner containing the highest X, Y, and Z.- Returns:
true
if thisCord
is inside the bounds,false
otherwise.- See Also:
-
inBounds
public boolean inBounds(double lowX, double highX, double lowY, double highY, double lowZ, double highZ) Checks if thisCord
lays inside the specified bounds.- Parameters:
lowX
- The lowest X of the bounds.highX
- The highest X of the bounds.lowY
- The lowest Y of the bounds.highY
- The highest Y of the bounds.lowZ
- The lowest Z of the bounds.highZ
- The highest Z of the bounds.- Returns:
true
if thisCord
is inside the bounds,false
otherwise.- See Also:
-
ofList
Converts a list of three objects, X, Y, and Z, into a Cord.- Parameters:
list
- The list to convert.- Returns:
- The converted Cord.
-
corners
@NotNull public static @NotNull Pair<Cord,Cord> corners(@NotNull @NotNull Cord corner1, @NotNull @NotNull Cord corner2) Converts two corners, so one has the lowest x, y and z and one has the highest x, y and z.- Parameters:
corner1
- The first corner.corner2
- The second corner.- Returns:
- A pair where the left side has the lower and the right the higher x, y and z.
Pair<Lowest XYZ, Highest XYZ>
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
x
public double x()Returns the value of thex
record component.- Returns:
- the value of the
x
record component
-
y
public double y()Returns the value of they
record component.- Returns:
- the value of the
y
record component
-
z
public double z()Returns the value of thez
record component.- Returns:
- the value of the
z
record component
-