Skip to content

jitx/shapes/Rectangle

Package name: jitx/shapes/Rectangle

Summary

Rectangle

Rectangle

Constructors

Function Description
Rectangle Constructor for defstruct Rectangle

Functions

Function Description
sw Retrieve the lower-left corner point of the rectangle.
normalize Create an equivalent rectangle with pose angle 0.0 for the given axis-aligned rectangle.
Rectangle (+ 2) Create a rectangle using Dims to specify the rectangle's dimensions.
ne Retrieve the upper-right corner point of the rectangle.

Definitions

Rectangle

Rectangle

public defstruct Rectangle <: Shape & Centerable & HasMetaUtils :
    height: Double
    pose: Pose
    width: Double

  • height: Double - Height of this rectangle. Must be non-negative.

  • pose: Pose - Pose of this rectangle. Default value is (0.0, 0.0) with no rotation and no flip.

  • width: Double - Width of this rectangle. Must be non-negative.

A rectangle with a width, height, and pose.

The pose center is the center of the rectangle. May be non-axis-aligned if the pose has non-zero rotation angle. The flip of the pose affects the ordering of the rectangle's points when converted to a polygon (clockwise when flipped, otherwise counter-clockwise).

Constructors

Rectangle

Constructor for defstruct Rectangle

public defn Rectangle (width:Double, height:Double, pose:Pose = ?)

Functions

sw

Retrieve the lower-left corner point of the rectangle.

public defn sw (r:Rectangle)

  • r: Rectangle - The rectangle to retrieve the lower-left corner point of.

normalize

Create an equivalent rectangle with pose angle 0.0 for the given axis-aligned rectangle.

public defn normalize (r:Rectangle)

  • r: Rectangle - The rectangle to create the equivalent of.
  • Throws Error - if the rectangle's pose angle is not axis-aligned.

Rectangle

Create a rectangle using Dims to specify the rectangle's dimensions.

public defn Rectangle (d:Dims, p:Pose = ?)

  • d: Dims - Dimensions of the rectangle
  • p: Pose - Pose of the rectangle. Default is (0.0, 0.0) with no rotation and no flip.

Rectangle

Create a rectangle anchored to a specified alignment with respect to the origin.

public defn Rectangle (anchor:Anchor, w:Double, h:Double)

  • anchor: Anchor - Anchor to align the rectangle with to the origin.
  • w: Double - Width of the rectangle.
  • h: Double - Height of the rectangle.

Rectangle

Create a rectangle with the coordinates of its bottom-left and upper-right points.

public defn Rectangle (x1:Double, y1:Double, x2:Double, y2:Double)

  • x1: Double - X coordinate of the bottom-left corner of the rectangle.
  • y1: Double - Y coordinate of the bottom-left corner of the rectangle.
  • x2: Double - X coordinate of the upper-right corner of the rectangle.
  • y2: Double - Y coordinate of the upper-right corner of the rectangle.

ne

Retrieve the upper-right corner point of the rectangle.

public defn ne (r:Rectangle)

  • r: Rectangle - The rectangle to retrieve the bottom-left corner point of.

Related Packages

Forwarded by packages: jitx/shapes, jitx