java.lang.Object
java.lang.Record
technology.sola.math.geometry.Rectangle
- Record Components:
min
- the top, left point of the rectanglemax
- the bottom, right point of the rectangle
- All Implemented Interfaces:
Shape
Rectangle represents an axis aligned geometric rectangle.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if this Shape contains a point.final boolean
Indicates whether some other object is "equal to" this one.float
getArea()
Calculates the area of this shape and return it.float
Gets the height of the rectangle.Vector2D[]
float
getWidth()
Gets the width of the rectangle.final int
hashCode()
Returns a hash code value for this object.boolean
intersects
(Rectangle rectangle) Checks to see if this Rectangle intersects with another Rectangle.max()
Returns the value of themax
record component.min()
Returns the value of themin
record component.final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface technology.sola.math.geometry.Shape
getCentroid
-
Constructor Details
-
Rectangle
Creates a rectangle by min and max points.The min point's x and y must both be below the max point's x and y. If they are the same then a degenerate rectangle with width or height of zero will be created.
- Parameters:
min
- the top, left point of the rectanglemax
- the bottom, right point of the rectangle
-
-
Method Details
-
contains
Description copied from interface:Shape
Checks if this Shape contains a point. -
getArea
public float getArea()Description copied from interface:Shape
Calculates the area of this shape and return it. -
getPoints
-
getWidth
public float getWidth()Gets the width of the rectangle.- Returns:
- the width
-
getHeight
public float getHeight()Gets the height of the rectangle.- Returns:
- the height
-
intersects
Checks to see if this Rectangle intersects with another Rectangle.- Parameters:
rectangle
- the other Rectangle to check intersection with- Returns:
- true if they are intersecting
-
getCenter
- Returns:
- the center point of the rectangle
-
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 withObjects::equals(Object,Object)
. -
min
Returns the value of themin
record component.- Returns:
- the value of the
min
record component
-
max
Returns the value of themax
record component.- Returns:
- the value of the
max
record component
-