Package org.joml
Class Rectangled
- java.lang.Object
-
- org.joml.Rectangled
-
- All Implemented Interfaces:
Externalizable,Serializable
public class Rectangled extends Object implements Externalizable
Represents a 2D axis-aligned rectangle.- Author:
- Kai Burjack
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Rectangled()Create a newRectangledwith a minimum and maximum corner of(0, 0).Rectangled(double minX, double minY, double maxX, double maxY)Create a newRectangledwith the given minimum and maximum corner coordinates.Rectangled(Rectangled source)Create a newRectangledas a copy of the givensource.Rectangled(Vector2dc min, Vector2dc max)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(double x, double y)Check if this rectangle contains the given point(x, y).booleancontains(Vector2d 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.Rectangledtranslate(double x, double y)Translatethisby the vector(x, y).Rectangledtranslate(double x, double y, Rectangled dest)Translatethisby the vector(x, y)and store the result indest.Rectangledtranslate(Vector2dc xy)Translatethisby the given vectorxy.Rectangledtranslate(Vector2dc xy, Rectangled dest)Translatethisby the given vectorxyand store the result indest.Rectangledtranslate(Vector2fc xy)Translatethisby the given vectorxy.Rectangledtranslate(Vector2fc xy, Rectangled dest)Translatethisby the given vectorxyand store the result indest.voidwriteExternal(ObjectOutput out)
-
-
-
Constructor Detail
-
Rectangled
public Rectangled()
Create a newRectangledwith a minimum and maximum corner of(0, 0).
-
Rectangled
public Rectangled(Rectangled source)
Create a newRectangledas a copy of the givensource.- Parameters:
source- theRectangledto copy from
-
Rectangled
public Rectangled(Vector2dc min, Vector2dc max)
- Parameters:
min- the minimum coordinatesmax- the maximum coordinates
-
Rectangled
public Rectangled(double minX, double minY, double maxX, double maxY)Create a newRectangledwith 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(Vector2d 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(double x, double 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 Rectangled translate(Vector2dc xy)
Translatethisby the given vectorxy.- Parameters:
xy- the vector to translate by- Returns:
- this
-
translate
public Rectangled translate(Vector2dc xy, Rectangled dest)
Translatethisby the given vectorxyand store the result indest.- Parameters:
xy- the vector to translate bydest- will hold the result- Returns:
- dest
-
translate
public Rectangled translate(Vector2fc xy)
Translatethisby the given vectorxy.- Parameters:
xy- the vector to translate by- Returns:
- this
-
translate
public Rectangled translate(Vector2fc xy, Rectangled dest)
Translatethisby the given vectorxyand store the result indest.- Parameters:
xy- the vector to translate bydest- will hold the result- Returns:
- dest
-
translate
public Rectangled translate(double x, double y)
Translatethisby the vector(x, y).- Parameters:
x- the x coordinate to translate byy- the y coordinate to translate by- Returns:
- this
-
translate
public Rectangled translate(double x, double y, Rectangled 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
-
-