geo2d.geometry.BoundingBox

class geo2d.geometry.BoundingBox(obj)[source]

Represents the far extremeties of another GeometricObject (except for Vector).

It is totally defined by two points. For convenience it also has left, top, right and bottom attributes.

Parameters :

obj : geometric object

The object for which to assign a BoundingBox.

Attributes

bottom [scalar]
height [scalar]
left [scalar]
p1 (point-like) Get the bottom-left Point.
p2 (point-like) Get the top-right Point.
right [scalar]
top [scalar]
width [scalar]

Methods

__contains__(x) Searches for x in “itself”.
__getitem__(idx) Get points through index.
__len__() The BoundingBox is made of 2 points so it’s length is 2.
intersection(obj) Return points of intersection if any.
rotate(theta[, point, angle]) Rotate self around pivot point.
translate(dx, dy) Translate self by given amounts on x and y.

Detailed description

class geo2d.geometry.BoundingBox(obj)[source]

Represents the far extremeties of another GeometricObject (except for Vector).

It is totally defined by two points. For convenience it also has left, top, right and bottom attributes.

Parameters :

obj : geometric object

The object for which to assign a BoundingBox.

__contains__(x)

Searches for x in “itself”. If we’re talking about a Point or a Vector then this searches within their components (x, y). For everything else it searches within the list of points (vertices).

Parameters :

x : {point, scalar}

The object to search for.

Returns :

out : {True, False}

True if we find x in self, else False.

__getitem__(idx)[source]

Get points through index.

Parameters :

idx : scalar

The index of the Point.

Returns :

out : point

The selected Point through the provided index.

__len__()[source]

The BoundingBox is made of 2 points so it’s length is 2.

bottom[source]

[scalar]

height[source]

[scalar]

intersection(obj)

Return points of intersection if any.

This method just calls the intersection method on the other objects that have it implemented.

Parameters :

obj : geometric object

obj is any object that has intersection implemented.

Returns :

ret : {point, None}

The point of intersection if any, if not, just None.

left[source]

[scalar]

p1[source]

(point-like) Get the bottom-left Point.

p2[source]

(point-like) Get the top-right Point.

right[source]

[scalar]

rotate(theta, point=None, angle='degrees')

Rotate self around pivot point.

Parameters :

theta : scalar

The angle to be rotated by.

point : {point-like}, optional

If given this will be used as the rotation pivot.

angle : {‘degrees’, ‘radians’}, optional

This tells the function how theta is passed: as degrees or as radians. Default is degrees.

top[source]

[scalar]

translate(dx, dy)

Translate self by given amounts on x and y.

Parameters :

dx, dy : scalar

Amount to translate (relative movement).

width[source]

[scalar]

[Arnon1983]Arnon et al., A Linear Time Algorithm for the Minimum Area Rectangle Enclosing a Convex Polygon” (1983), Computer Science Technical Reports. Paper 382
[WPolygon]http://en.wikipedia.org/wiki/Polygon

Previous topic

geo2d.geometry.Vector

Next topic

geo2d.geometry.Line

This Page