Package org.joml
Class Rectanglef
- java.lang.Object
-
- org.joml.Rectanglef
-
- All Implemented Interfaces:
Externalizable,Serializable
public class Rectanglef extends Object implements Externalizable
Represents a 2D axis-aligned rectangle.- Author:
- Kai Burjack
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Rectanglef()Create a newRectanglefwith a minimum and maximum corner of(0, 0).Rectanglef(float minX, float minY, float maxX, float maxY)Create a newRectanglefwith the given minimum and maximum corner coordinates.Rectanglef(Rectanglef source)Create a newRectanglefas a copy of the givensource.Rectanglef(Vector2fc min, Vector2fc max)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(float x, float y)Check if this rectangle contains the given point(x, y).booleancontains(Vector2f point)Check if this rectangle contains the givenpoint.booleanequals(Object obj)inthashCode()booleanintersects(Rectangled other)Check if this and the given rectangle intersect.voidreadExternal(ObjectInput in)StringtoString()Return a string representation of this rectangle.StringtoString(NumberFormat formatter)Return a string representation of this rectangle by formatting the vector components with the givenNumberFormat.Rectangleftranslate(float x, float y)Translatethisby the vector(x, y).Rectangleftranslate(float x, float y, Rectanglef dest)Translatethisby the vector(x, y)and store the result indest.Rectangleftranslate(Vector2fc xy)Translatethisby the given vectorxy.Rectangleftranslate(Vector2fc xy, Rectanglef dest)Translatethisby the given vectorxyand store the result indest.voidwriteExternal(ObjectOutput out)
-
-
-
Constructor Detail
-
Rectanglef
public Rectanglef()
Create a newRectanglefwith a minimum and maximum corner of(0, 0).
-
Rectanglef
public Rectanglef(Rectanglef source)
Create a newRectanglefas a copy of the givensource.- Parameters:
source- theRectanglefto copy from
-
Rectanglef
public Rectanglef(Vector2fc min, Vector2fc max)
- Parameters:
min- the minimum coordinatesmax- the maximum coordinates
-
Rectanglef
public Rectanglef(float minX, float minY, float maxX, float maxY)Create a newRectanglefwith the given minimum and maximum corner coordinates.- Parameters:
minX- the x coordinate of the minimum cornerminY- the y coordinate of the minimum cornermaxX- the x coordinate of the maximum cornermaxY- the y coordinate of the maximum corner
-
-
Method Detail
-
intersects
public boolean intersects(Rectangled other)
Check if this and the given rectangle intersect.- Parameters:
other- the other rectangle- Returns:
trueiff both rectangles intersect;falseotherwise
-
contains
public boolean contains(Vector2f point)
Check if this rectangle contains the givenpoint.- Parameters:
point- the point to test- Returns:
trueiff this rectangle contains the point;falseotherwise
-
contains
public boolean contains(float x, float y)Check if this rectangle contains the given point(x, y).- Parameters:
x- the x coordinate of the point to checky- the y coordinate of the point to check- Returns:
trueiff this rectangle contains the point;falseotherwise
-
translate
public Rectanglef translate(Vector2fc xy)
Translatethisby the given vectorxy.- Parameters:
xy- the vector to translate by- Returns:
- this
-
translate
public Rectanglef translate(Vector2fc xy, Rectanglef dest)
Translatethisby the given vectorxyand store the result indest.- Parameters:
xy- the vector to translate bydest- will hold the result- Returns:
- dest
-
translate
public Rectanglef translate(float x, float y)
Translatethisby the vector(x, y).- Parameters:
x- the x coordinate to translate byy- the y coordinate to translate by- Returns:
- this
-
translate
public Rectanglef translate(float x, float y, Rectanglef dest)
Translatethisby the vector(x, y)and store the result indest.- Parameters:
x- the x coordinate to translate byy- the y coordinate to translate bydest- will hold the result- Returns:
- dest
-
toString
public String toString()
Return a string representation of this rectangle.This method creates a new
DecimalFormaton every invocation with the format string "0.000E0;-".
-
toString
public String toString(NumberFormat formatter)
Return a string representation of this rectangle by formatting the vector components with the givenNumberFormat.- Parameters:
formatter- theNumberFormatused to format the vector components with- Returns:
- the string representation
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-