Package eu.svjatoslav.sixth.e3d.geometry
Class Rectangle
java.lang.Object
eu.svjatoslav.sixth.e3d.geometry.Rectangle
A 2D axis-aligned rectangle defined by two corner points.
The rectangle is defined by two points (p1 and p2) that represent
opposite corners. The rectangle does not enforce ordering of these points.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the height of the rectangle (distance along the Y-axis).doubleReturns the leftmost X coordinate of the rectangle.doubleReturns the topmost Y coordinate of the rectangle.doublegetWidth()Returns the width of the rectangle (distance along the X-axis).
-
Field Details
-
p1
The corner points of the rectangle (opposite corners). -
p2
The corner points of the rectangle (opposite corners).
-
-
Constructor Details
-
Rectangle
public Rectangle(double size) Creates a square rectangle centered at the origin with the specified size.- Parameters:
size- the width and height of the square
-
Rectangle
Creates a rectangle with the specified corner points.- Parameters:
p1- the first corner pointp2- the second corner point (opposite corner)
-
-
Method Details
-
getHeight
public double getHeight()Returns the height of the rectangle (distance along the Y-axis).- Returns:
- the height (always positive)
-
getLowerX
public double getLowerX()Returns the leftmost X coordinate of the rectangle.- Returns:
- the minimum X value
-
getLowerY
public double getLowerY()Returns the topmost Y coordinate of the rectangle.- Returns:
- the minimum Y value
-
getWidth
public double getWidth()Returns the width of the rectangle (distance along the X-axis).- Returns:
- the width (always positive)
-