Chemical Data Processing Library Python API - Version 1.1.1
|
Specifies an axis aligned rectangular area in 2D space. More...
Public Member Functions | |
None | __init__ () |
Constructs an undefined rectangle. More... | |
None | __init__ (Rectangle2D rect) |
Initializes a copy of the Rectangle2D instance rect. More... | |
None | __init__ (Math.Vector2D min, Math.Vector2D max) |
Constructs a rectangle with the minimum point set to min and the maximum point set to max. More... | |
None | __init__ (float min_x, float min_y, float max_x, float max_y) |
Constructs a rectangle with the minimum point set to (min_x, min_y) and the maximum point set to (max_x, max_y). More... | |
int | getObjectID () |
Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
Rectangle2D | assign (Rectangle2D rect) |
Replaces the current state of self with a copy of the state of the Rectangle2D instance rect. More... | |
bool | isDefined () |
Tells if the rectangle is well defined. More... | |
None | addPoint (Math.Vector2D pt) |
Adds the point pt to the current rectangle. More... | |
None | addPoint (float x, float y) |
Adds the point (x, y) to the current rectangle. More... | |
None | addMargin (float width, float height) |
Extends the rectangle by adding a margin with the specified width and height. More... | |
None | addRectangle (Rectangle2D rect) |
Adds the rectangle rect to the current rectangle. More... | |
bool | containsPoint (Math.Vector2D pt) |
Tests if the point pt is within the boundary of the rectangle. More... | |
bool | containsPoint (float x, float y) |
Tests if the point (x, y) is within the boundary of the rectangle. More... | |
bool | containsRectangle (Rectangle2D rect) |
Tests if the specified rectangle rect is within the boundary of this rectangle. More... | |
bool | intersectsRectangle (Rectangle2D rect) |
Tests if the interior of this rectangle intersects the rectangle rect. More... | |
None | setMin (Math.Vector2D pt) |
Sets the minimum point of the rectangle to pt. More... | |
None | setMin (float x, float y) |
Sets the minimum point of the rectangle to (x, y). More... | |
None | setMax (Math.Vector2D pt) |
Sets the maximum point of the rectangle to pt. More... | |
None | setMax (float x, float y) |
Sets the maximum point of the rectangle to (x, y). More... | |
None | setBounds (Math.Vector2D min, Math.Vector2D max) |
Sets the minimum point of the rectangle to min and the maximum point to max. More... | |
None | setBounds (float min_x, float min_y, float max_x, float max_y) |
Sets the minimum point of the rectangle to (min_x, min_y) and the maximum point to (max_x, max_y). More... | |
Math.Vector2D | getMin () |
Returns the minimum point of the rectangle. More... | |
Math.Vector2D | getMax () |
Returns the maximum point of the rectangle. More... | |
Math.Vector2D | getCenter () |
Calculates the center of the rectangle. More... | |
None | getCenter (Math.Vector2D ctr) |
Calculates the center of the rectangle and stores the result in ctr. More... | |
float | getArea () |
Calculates the area of the rectangle. More... | |
float | getWidth () |
Returns the width of the rectangle. More... | |
float | getHeight () |
Returns the height of the rectangle. More... | |
None | reset () |
Resets the rectangle to an undefinded state. More... | |
None | scale (float factor) |
Scales the minimum and maximum point of the rectangle by the specified factor. More... | |
None | translate (Math.Vector2D vec) |
Translates the minimum and maximum point of the rectangle by vec. More... | |
str | __str__ () |
Returns a string representation of the Rectangle2D instance. More... | |
bool | __eq__ (Rectangle2D rect) |
Equality comparison operator. More... | |
bool | __ne__ (Rectangle2D rect) |
Inequality comparison operator. More... | |
bool | __contains__ (Math.Vector2D pt) |
Returns the result of the membership test operation pt in self . More... | |
bool | __contains__ (Rectangle2D rect) |
Returns the result of the membership test operation rect in self . More... | |
Properties | |
objectID = property(getObjectID) | |
defined = property(isDefined) | |
min = property(getMin, setMin) | |
max = property(getMax, setMax) | |
center = property(getCenter) | |
width = property(getWidth) | |
height = property(getHeight) | |
area = property(getArea) | |
Specifies an axis aligned rectangular area in 2D space.
The rectangle is defined by a minimum point \( (x_{min}, y_{min}) \) and a maximum point \( (x_{max}, y_{max}) \). For a well defined rectangle the coordinates of the minimum and maximum point must satisfy the follwing inequalities: \( x_{min} \leq x_{max} \) and \( y_{min} \leq y_{max} \).
None CDPL.Vis.Rectangle2D.__init__ | ( | ) |
Constructs an undefined rectangle.
The coordinates of the minimum point are set to std::numeric_limits<double>.max()
and the coordinates of the maximum point are set to -
. std::numeric_limits<double>.max()
None CDPL.Vis.Rectangle2D.__init__ | ( | Rectangle2D | rect | ) |
Initializes a copy of the Rectangle2D instance rect.
rect | The Rectangle2D instance to copy. |
None CDPL.Vis.Rectangle2D.__init__ | ( | Math.Vector2D | min, |
Math.Vector2D | max | ||
) |
Constructs a rectangle with the minimum point set to min and the maximum point set to max.
min | The minimum point. |
max | The maximum point. |
None CDPL.Vis.Rectangle2D.__init__ | ( | float | min_x, |
float | min_y, | ||
float | max_x, | ||
float | max_y | ||
) |
Constructs a rectangle with the minimum point set to (min_x, min_y) and the maximum point set to (max_x, max_y).
min_x | The x-coordinate of the minimum point. |
min_y | The y-coordinate of the minimum point. |
max_x | The x-coordinate of the maximum point. |
max_y | The y-coordinate of the maximum point. |
int CDPL.Vis.Rectangle2D.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python Rectangle2D instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b
thus cannot tell reliably whether the two Rectangle2D instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID()
.
Rectangle2D CDPL.Vis.Rectangle2D.assign | ( | Rectangle2D | rect | ) |
Replaces the current state of self with a copy of the state of the Rectangle2D instance rect.
rect | The Rectangle2D instance to copy. |
bool CDPL.Vis.Rectangle2D.isDefined | ( | ) |
Tells if the rectangle is well defined.
The rectangle is well defined if neither the height nor the width of the rectangle is negative.
True
if the rectangle is defined, and False
otherwise.None CDPL.Vis.Rectangle2D.addPoint | ( | Math.Vector2D | pt | ) |
Adds the point pt to the current rectangle.
The resulting (adjusted) rectangle represents the smallest rectangular area that contains both the original rectangle and the specified point pt.
pt | The point to add. |
None CDPL.Vis.Rectangle2D.addPoint | ( | float | x, |
float | y | ||
) |
Adds the point (x, y) to the current rectangle.
The resulting (adjusted) rectangle represents the smallest rectangular area that contains both the original rectangle and the specified point (x, y).
x | The x-coordinate of the point to add. |
y | The y-coordinate of the point to add. |
None CDPL.Vis.Rectangle2D.addMargin | ( | float | width, |
float | height | ||
) |
Extends the rectangle by adding a margin with the specified width and height.
The minimum point gets translated by (-width, -height) and the maximum point by (width, height).
width | The amount the rectangle will be extended horizontally. |
height | The amount the rectangle will be extended vertically. |
None CDPL.Vis.Rectangle2D.addRectangle | ( | Rectangle2D | rect | ) |
Adds the rectangle rect to the current rectangle.
The resulting rectangle is the union of the two rectangle objects and contains both the original rectangle and the specified rectangle rect.
rect | The other rectangle to add. |
bool CDPL.Vis.Rectangle2D.containsPoint | ( | Math.Vector2D | pt | ) |
Tests if the point pt is within the boundary of the rectangle.
A point lying exactly on one of the edges or corners is also considered to be within the boundaries.
pt | The point to test. |
True
if pt is within the boundary of the rectangle, and False
otherwise. bool CDPL.Vis.Rectangle2D.containsPoint | ( | float | x, |
float | y | ||
) |
Tests if the point (x, y) is within the boundary of the rectangle.
A point lying exactly on one of the edges or corners is also considered to be within the boundaries.
x | The x-coordinate of the point to test. |
y | The y-coordinate of the point to test. |
True
if the point (x, y) is within the boundary of the rectangle, and False
otherwise. bool CDPL.Vis.Rectangle2D.containsRectangle | ( | Rectangle2D | rect | ) |
Tests if the specified rectangle rect is within the boundary of this rectangle.
The result is equivalent to (this->containsPoint(rect.getMin()) && this->containsPoint(rect.getMax()))
.
rect | The rectangle to test. |
True
if the rectangle rect is within the boundary of this rectangle, and False
otherwise. bool CDPL.Vis.Rectangle2D.intersectsRectangle | ( | Rectangle2D | rect | ) |
Tests if the interior of this rectangle intersects the rectangle rect.
If the rectangles overlap only on one of their edges or corners, they are also considered to intersect.
rect | The rectangle to test. |
True
if the rectangles intersect, and False
otherwise. None CDPL.Vis.Rectangle2D.setMin | ( | Math.Vector2D | pt | ) |
Sets the minimum point of the rectangle to pt.
pt | The new minimum point. |
None CDPL.Vis.Rectangle2D.setMin | ( | float | x, |
float | y | ||
) |
Sets the minimum point of the rectangle to (x, y).
x | The x-coordinate of the new minimum point. |
y | The y-coordinate of the new minimum point. |
None CDPL.Vis.Rectangle2D.setMax | ( | Math.Vector2D | pt | ) |
Sets the maximum point of the rectangle to pt.
pt | The new maximum point. |
None CDPL.Vis.Rectangle2D.setMax | ( | float | x, |
float | y | ||
) |
Sets the maximum point of the rectangle to (x, y).
x | The x-coordinate of the new maximum point. |
y | The y-coordinate of the new maximum point. |
None CDPL.Vis.Rectangle2D.setBounds | ( | Math.Vector2D | min, |
Math.Vector2D | max | ||
) |
Sets the minimum point of the rectangle to min and the maximum point to max.
min | The new minimum point. |
max | The new maximum point. |
None CDPL.Vis.Rectangle2D.setBounds | ( | float | min_x, |
float | min_y, | ||
float | max_x, | ||
float | max_y | ||
) |
Sets the minimum point of the rectangle to (min_x, min_y) and the maximum point to (max_x, max_y).
min_x | The x-coordinate of the new minimum point. |
min_y | The y-coordinate of the new minimum point. |
max_x | The x-coordinate of the new maximum point. |
max_y | The y-coordinate of the new maximum point. |
Math.Vector2D CDPL.Vis.Rectangle2D.getMin | ( | ) |
Returns the minimum point of the rectangle.
Math.Vector2D CDPL.Vis.Rectangle2D.getMax | ( | ) |
Returns the maximum point of the rectangle.
Math.Vector2D CDPL.Vis.Rectangle2D.getCenter | ( | ) |
Calculates the center of the rectangle.
None CDPL.Vis.Rectangle2D.getCenter | ( | Math.Vector2D | ctr | ) |
Calculates the center of the rectangle and stores the result in ctr.
ctr | A vector storing the calculated center point. |
float CDPL.Vis.Rectangle2D.getArea | ( | ) |
Calculates the area of the rectangle.
float CDPL.Vis.Rectangle2D.getWidth | ( | ) |
Returns the width of the rectangle.
The width of the rectangle is the difference \( x_{max} - x_{min} \) between the x-coordinate of the maximum point \( x_{max} \) and the x-coordinate of the minimum point \( x_{min} \).
float CDPL.Vis.Rectangle2D.getHeight | ( | ) |
Returns the height of the rectangle.
The height of the rectangle is the difference \( y_{max} - y_{min} \) between the y-coordinate of the maximum point \( y_{max} \) and the y-coordinate of the minimum point \( y_{min} \).
None CDPL.Vis.Rectangle2D.reset | ( | ) |
Resets the rectangle to an undefinded state.
The coordinates of the minimum point are set to std::numeric_limits<double>.max()
and the coordinates of the maximum point are set to -
. std::numeric_limits<double>.max()
None CDPL.Vis.Rectangle2D.scale | ( | float | factor | ) |
Scales the minimum and maximum point of the rectangle by the specified factor.
factor | The scaling factor. |
None CDPL.Vis.Rectangle2D.translate | ( | Math.Vector2D | vec | ) |
Translates the minimum and maximum point of the rectangle by vec.
vec | The translation vector. |
str CDPL.Vis.Rectangle2D.__str__ | ( | ) |
Returns a string representation of the Rectangle2D instance.
bool CDPL.Vis.Rectangle2D.__eq__ | ( | Rectangle2D | rect | ) |
Equality comparison operator.
rect | The other Rectangle2D object to be compared with. |
True
if the minimum and maximum points compare equal, and False
otherwise. bool CDPL.Vis.Rectangle2D.__ne__ | ( | Rectangle2D | rect | ) |
Inequality comparison operator.
The result is equivalent to !(self == rect)
.
rect | The other Rectangle2D object to be compared with. |
True
if either the minimum or maximum points compare non-equal, and False
otherwise. bool CDPL.Vis.Rectangle2D.__contains__ | ( | Math.Vector2D | pt | ) |
Returns the result of the membership test operation pt in self
.
pt | The value to test for membership. |
bool CDPL.Vis.Rectangle2D.__contains__ | ( | Rectangle2D | rect | ) |
Returns the result of the membership test operation rect in self
.
rect | The value to test for membership. |