Class Rectangle

java.lang.Object
eu.svjatoslav.sixth.e3d.geometry.Rectangle

public class Rectangle extends Object
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
    Modifier and Type
    Field
    Description
    The corner points of the rectangle (opposite corners).
    The corner points of the rectangle (opposite corners).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rectangle(double size)
    Creates a square rectangle centered at the origin with the specified size.
    Creates a rectangle with the specified corner points.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the height of the rectangle (distance along the Y-axis).
    double
    Returns the leftmost X coordinate of the rectangle.
    double
    Returns the topmost Y coordinate of the rectangle.
    double
    Returns the width of the rectangle (distance along the X-axis).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • p1

      public Point2D p1
      The corner points of the rectangle (opposite corners).
    • p2

      public Point2D 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

      public Rectangle(Point2D p1, Point2D p2)
      Creates a rectangle with the specified corner points.
      Parameters:
      p1 - the first corner point
      p2 - 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)