ZLayout EDA Library v1.0.0
Advanced Electronic Design Automation Layout Library with Bilingual Documentation
|
Axis-aligned rectangle for bounding boxes and simple EDA components. More...
#include <rectangle.hpp>
Public Member Functions | |
Rectangle () | |
Default constructor - creates empty rectangle at origin. | |
Rectangle (double x, double y, double width, double height) | |
Constructor with position and dimensions. | |
Rectangle (const Point &bottom_left, const Point &top_right) | |
Constructor from two corner points. | |
Rectangle (const Rectangle &other)=default | |
Copy constructor. | |
Rectangle & | operator= (const Rectangle &other)=default |
Assignment operator. | |
bool | operator== (const Rectangle &other) const |
Equality operator. | |
bool | operator!= (const Rectangle &other) const |
Inequality operator. | |
bool | operator< (const Rectangle &other) const |
Less than operator for sorting. | |
double | left () const |
Get left edge X coordinate. | |
double | right () const |
Get right edge X coordinate. | |
double | bottom () const |
Get bottom edge Y coordinate. | |
double | top () const |
Get top edge Y coordinate. | |
Point | center () const |
Get center point of rectangle. | |
Point | bottom_left () const |
Get bottom-left corner point. | |
Point | bottom_right () const |
Get bottom-right corner point. | |
Point | top_left () const |
Get top-left corner point. | |
Point | top_right () const |
Get top-right corner point. | |
std::vector< Point > | corners () const |
Get all four corner points. | |
double | area () const |
Calculate rectangle area. | |
double | perimeter () const |
Calculate rectangle perimeter. | |
bool | is_empty () const |
Check if rectangle is empty (zero area) | |
bool | is_valid () const |
Check if rectangle is valid (positive dimensions) | |
bool | contains_point (const Point &point) const |
Check if point is inside rectangle (inclusive of boundary) | |
bool | contains_rectangle (const Rectangle &other) const |
Check if another rectangle is completely inside this rectangle. | |
bool | intersects (const Rectangle &other) const |
Check if this rectangle intersects with another rectangle. | |
Rectangle | intersection (const Rectangle &other) const |
Calculate intersection rectangle with another rectangle. | |
Rectangle | union_with (const Rectangle &other) const |
Calculate union rectangle that contains both rectangles. | |
Rectangle | expand (double margin) const |
Expand rectangle by given margin in all directions. | |
Rectangle | expand (double left, double right, double bottom, double top) const |
Expand rectangle by different margins in each direction. | |
Rectangle | translate (const Point &offset) const |
Translate rectangle by given offset. | |
Rectangle | scale (double factor) const |
Scale rectangle by given factor (around center) | |
Rectangle | scale (double x_factor, double y_factor) const |
Scale rectangle by different factors in X and Y. | |
double | distance_to (const Rectangle &other) const |
Calculate minimum distance to another rectangle. | |
double | distance_to (const Point &point) const |
Calculate minimum distance to a point. | |
Polygon | to_polygon () const |
Convert rectangle to polygon representation. | |
std::string | to_string () const |
Get string representation. | |
__init__ (self, float x, float y, float width, float height) | |
str | __repr__ (self) |
float | left (self) |
float | right (self) |
float | top (self) |
float | bottom (self) |
Point | center (self) |
bool | contains_point (self, Point point) |
bool | intersects (self, 'Rectangle' other) |
'Polygon' | to_polygon (self) |
Static Public Member Functions | |
static Rectangle | from_center (const Point ¢er, double width, double height) |
Create rectangle from center point and dimensions. | |
static Rectangle | bounding_box (const std::vector< Point > &points) |
Create bounding rectangle for a set of points. | |
static Rectangle | bounding_box (const std::vector< Rectangle > &rectangles) |
Create rectangle that bounds multiple rectangles. |
Public Attributes | |
double | x |
X coordinate of bottom-left corner. | |
double | y |
Y coordinate of bottom-left corner. | |
double | width |
Width of rectangle. | |
double | height |
Height of rectangle. | |
x = float(x) | |
y = float(y) | |
width = float(width) | |
height = float(height) | |
bottom |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Rectangle &rect) |
Stream output operator. |
Axis-aligned rectangle for bounding boxes and simple EDA components.
Axis-aligned rectangle for bounding boxes and simple components.
Represents an axis-aligned rectangle in 2D space. Commonly used for component bounding boxes, chip outlines, and simple rectangular components in EDA layouts.
Definition at line 26 of file rectangle.hpp.
|
inline |
Default constructor - creates empty rectangle at origin.
Definition at line 36 of file rectangle.hpp.
zlayout::geometry::Rectangle::Rectangle | ( | double | x, |
double | y, | ||
double | width, | ||
double | height ) |
Constructor with position and dimensions.
x | X coordinate of bottom-left corner |
y | Y coordinate of bottom-left corner |
width | Rectangle width |
height | Rectangle height |
Definition at line 16 of file rectangle.cpp.
Constructor from two corner points.
bottom_left | Bottom-left corner |
top_right | Top-right corner |
Definition at line 23 of file rectangle.cpp.
|
default |
Copy constructor.
zlayout.geometry.Rectangle.__init__ | ( | self, | |
float | x, | ||
float | y, | ||
float | width, | ||
float | height ) |
Definition at line 72 of file geometry.py.
str zlayout.geometry.Rectangle.__repr__ | ( | self | ) |
Definition at line 78 of file geometry.py.
|
inline |
Calculate rectangle area.
Definition at line 134 of file rectangle.hpp.
float zlayout.geometry.Rectangle.bottom | ( | self | ) |
Definition at line 94 of file geometry.py.
|
inline |
Get bottom edge Y coordinate.
Definition at line 93 of file rectangle.hpp.
|
inline |
Get bottom-left corner point.
Definition at line 108 of file rectangle.hpp.
|
inline |
Get bottom-right corner point.
Definition at line 113 of file rectangle.hpp.
Create bounding rectangle for a set of points.
points | Vector of points |
Definition at line 221 of file rectangle.cpp.
|
static |
Create rectangle that bounds multiple rectangles.
rectangles | Vector of rectangles |
Definition at line 239 of file rectangle.cpp.
Point zlayout.geometry.Rectangle.center | ( | self | ) |
Definition at line 98 of file geometry.py.
Point zlayout::geometry::Rectangle::center | ( | ) | const |
Get center point of rectangle.
Definition at line 68 of file rectangle.cpp.
bool zlayout.geometry.Rectangle.contains_point | ( | self, | |
Point | point ) |
Check if point is inside rectangle.
Definition at line 101 of file geometry.py.
bool zlayout::geometry::Rectangle::contains_point | ( | const Point & | point | ) | const |
Check if point is inside rectangle (inclusive of boundary)
point | Point to test |
Definition at line 89 of file rectangle.cpp.
bool zlayout::geometry::Rectangle::contains_rectangle | ( | const Rectangle & | other | ) | const |
Check if another rectangle is completely inside this rectangle.
other | Rectangle to test |
Definition at line 94 of file rectangle.cpp.
std::vector< Point > zlayout::geometry::Rectangle::corners | ( | ) | const |
Get all four corner points.
Definition at line 72 of file rectangle.cpp.
double zlayout::geometry::Rectangle::distance_to | ( | const Point & | point | ) | const |
Calculate minimum distance to a point.
point | Target point |
Definition at line 187 of file rectangle.cpp.
double zlayout::geometry::Rectangle::distance_to | ( | const Rectangle & | other | ) | const |
Calculate minimum distance to another rectangle.
other | Target rectangle |
Definition at line 164 of file rectangle.cpp.
Rectangle zlayout::geometry::Rectangle::expand | ( | double | left, |
double | right, | ||
double | bottom, | ||
double | top ) const |
Expand rectangle by different margins in each direction.
left | Left margin |
right | Right margin |
bottom | Bottom margin |
top | Top margin |
Definition at line 135 of file rectangle.cpp.
Rectangle zlayout::geometry::Rectangle::expand | ( | double | margin | ) | const |
Expand rectangle by given margin in all directions.
margin | Margin to add (can be negative to shrink) |
Definition at line 130 of file rectangle.cpp.
|
static |
Create rectangle from center point and dimensions.
Definition at line 217 of file rectangle.cpp.
Calculate intersection rectangle with another rectangle.
other | Rectangle to intersect with |
Definition at line 105 of file rectangle.cpp.
bool zlayout.geometry.Rectangle.intersects | ( | self, | |
'Rectangle' | other ) |
Check if this rectangle intersects with another.
Definition at line 106 of file geometry.py.
bool zlayout::geometry::Rectangle::intersects | ( | const Rectangle & | other | ) | const |
Check if this rectangle intersects with another rectangle.
other | Rectangle to test intersection with |
Definition at line 100 of file rectangle.cpp.
bool zlayout::geometry::Rectangle::is_empty | ( | ) | const |
Check if rectangle is empty (zero area)
Definition at line 81 of file rectangle.cpp.
bool zlayout::geometry::Rectangle::is_valid | ( | ) | const |
Check if rectangle is valid (positive dimensions)
Definition at line 85 of file rectangle.cpp.
float zlayout.geometry.Rectangle.left | ( | self | ) |
Definition at line 82 of file geometry.py.
|
inline |
Get left edge X coordinate.
Definition at line 83 of file rectangle.hpp.
bool zlayout::geometry::Rectangle::operator!= | ( | const Rectangle & | other | ) | const |
Inequality operator.
Definition at line 37 of file rectangle.cpp.
bool zlayout::geometry::Rectangle::operator< | ( | const Rectangle & | other | ) | const |
Less than operator for sorting.
Definition at line 41 of file rectangle.cpp.
Assignment operator.
bool zlayout::geometry::Rectangle::operator== | ( | const Rectangle & | other | ) | const |
Equality operator.
Definition at line 30 of file rectangle.cpp.
|
inline |
Calculate rectangle perimeter.
Definition at line 139 of file rectangle.hpp.
float zlayout.geometry.Rectangle.right | ( | self | ) |
Definition at line 86 of file geometry.py.
|
inline |
Get right edge X coordinate.
Definition at line 88 of file rectangle.hpp.
Rectangle zlayout::geometry::Rectangle::scale | ( | double | factor | ) | const |
Scale rectangle by given factor (around center)
factor | Scale factor |
Definition at line 144 of file rectangle.cpp.
Rectangle zlayout::geometry::Rectangle::scale | ( | double | x_factor, |
double | y_factor ) const |
Scale rectangle by different factors in X and Y.
x_factor | X scale factor |
y_factor | Y scale factor |
Definition at line 154 of file rectangle.cpp.
'Polygon' zlayout.geometry.Rectangle.to_polygon | ( | self | ) |
Convert rectangle to polygon.
Definition at line 111 of file geometry.py.
Polygon zlayout::geometry::Rectangle::to_polygon | ( | ) | const |
Convert rectangle to polygon representation.
Definition at line 198 of file rectangle.cpp.
std::string zlayout::geometry::Rectangle::to_string | ( | ) | const |
Get string representation.
Definition at line 203 of file rectangle.cpp.
float zlayout.geometry.Rectangle.top | ( | self | ) |
Definition at line 90 of file geometry.py.
|
inline |
Get top edge Y coordinate.
Definition at line 98 of file rectangle.hpp.
|
inline |
Get top-left corner point.
Definition at line 118 of file rectangle.hpp.
|
inline |
Get top-right corner point.
Definition at line 123 of file rectangle.hpp.
Translate rectangle by given offset.
offset | Translation vector |
Definition at line 140 of file rectangle.cpp.
Calculate union rectangle that contains both rectangles.
other | Rectangle to union with |
Definition at line 118 of file rectangle.cpp.
|
friend |
Stream output operator.
Definition at line 210 of file rectangle.cpp.
zlayout.geometry.Rectangle.bottom |
Definition at line 109 of file geometry.py.
zlayout.geometry.Rectangle.height = float(height) |
Definition at line 76 of file geometry.py.
double zlayout::geometry::Rectangle::height |
Height of rectangle.
Definition at line 31 of file rectangle.hpp.
zlayout.geometry.Rectangle.width = float(width) |
Definition at line 75 of file geometry.py.
double zlayout::geometry::Rectangle::width |
Width of rectangle.
Definition at line 30 of file rectangle.hpp.
zlayout.geometry.Rectangle.x = float(x) |
Definition at line 73 of file geometry.py.
double zlayout::geometry::Rectangle::x |
X coordinate of bottom-left corner.
Definition at line 28 of file rectangle.hpp.
zlayout.geometry.Rectangle.y = float(y) |
Definition at line 74 of file geometry.py.
double zlayout::geometry::Rectangle::y |
Y coordinate of bottom-left corner.
Definition at line 29 of file rectangle.hpp.