Module rectangle

Module rectangle 

Source
Expand description

§Geometry Rectangle Module

This module provides generic, N-dimensional rectangles and related utilities for geometric computations. It supports rectangles in arbitrary dimensions, with methods for construction, manipulation, cropping, intersection, and iteration.

§Features

  • Generic Rectangle<T, N> type for N-dimensional rectangles
  • Construction from position and size, or from two corner points
  • Querying rectangle corners, edges, and center points
  • Cropping and margin operations
  • Intersection checks
  • Iteration over rectangle indices (for integer types)
  • Traits for rectangle-like types (IRectangle, Crop)

§Usage

use hexga_math::prelude::*;

let rect = rect2i(0, 0, 10, 10);
assert!(rect.is_inside(point2(5, 5)));

let cropped = rect.crop_margin_intersect(point2(2, 2), point2(2, 2));
assert_eq!(cropped, rect2i(2, 2, 6, 6));

§See Also

Modules§

prelude

Structs§

RectangleIter
Iter over all idx inside a rectangle
RectangleOf
A N dimension rectangle

Traits§

Crop
Crop a selection to a sub selection, where the sub selection is contained in the selection.
GetRectangle
SetRectangle

Functions§

rect1
rect2
rect3
rect4
rect1i
rect2i
rect3i
rect4i
rectangle1
rectangle2
rectangle3
rectangle4

Type Aliases§

Rect1
Rect2
Rect3
Rect4
Rect1i
Rect2i
Rect3i
Rect4i
Rectangle
Rectangle1
Rectangle2
Rectangle3
Rectangle4