mt.geo2d.rect

A 2D rectangle.

Functions

mt.geo2d.rect.cast_Hyperbox_to_Rect(x)

Casts a Hyperbox to a Rect.

mt.geo2d.rect.cast_Rect_to_Moments2d(obj)
mt.geo2d.rect.approx_Moments2d_to_Rect(obj)

Approximates a Moments2d instance with a rect such that the mean aligns with the rect’s center, and the covariance matrix of the instance is closest to the moment convariance matrix of the rect.

Classes

  • Rect: A 2D rectangle,

class mt.geo2d.rect.Rect(min_x, min_y, max_x, max_y, force_valid=False)

A 2D rectangle,

Note we do not care if the rectangle is open or partially closed or closed.

Inheritance

digraph inheritance2ad3552943 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GeometricObject" [URL="../mt.geo/mt.geo.object.html#mt.geo.object.GeometricObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A geometric object which lives in a d-dimensional Euclidean space."]; "HasShapely" [URL="mt.geo2d.shapely.html#mt.geo2d.shapely.HasShapely",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin to assert that the geometric object has the 'shapely' property."]; "Hyperbox" [URL="../mt.geond/mt.geond.hyperbox.html#mt.geond.hyperbox.Hyperbox",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Axis-aligned n-dimensional hyperrectangle."]; "GeometricObject" -> "Hyperbox" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Rect" [URL="#mt.geo2d.rect.Rect",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A 2D rectangle,"]; "HasShapely" -> "Rect" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TwoD" -> "Rect" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Hyperbox" -> "Rect" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TwoD" [URL="../mt.geo/mt.geo.object.html#mt.geo.object.TwoD",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin to assert that the geometric object lives in 2D Euclidean space."]; }
__init__(min_x, min_y, max_x, max_y, force_valid=False)
__repr__()

Return repr(self).

property area

Absolute area.

property center_pt

Center point.

property circumference

Circumference.

property cx

Center x-coordinate.

property cy

Center y-coordinate.

static from_json(json_obj)

Creates a Rect from a JSON-like object.

Parameters:

json_obj (list) – list [min_x, min_y, max_x, max_y]

Returns:

output rectangle

Return type:

Rect

property h

height

property max_pt

Corner point with maximum coordinates.

property max_x

highest x-coordinate.

property max_y

highest y-coordinate.

property min_pt

Corner point with minimum coordinates.

property min_x

lowest x-coordinate.

property min_y

lowest x-coodinate.

property moment1

First-order moment.

property moment2

Second-order moment.

property moment_x

Returns the integral of x over the rectangle’s interior.

property moment_xx

Returns the integral of x*x over the rectangle’s interior.

property moment_xy

Returns the integral of x*y over the rectangle’s interior.

property moment_y

Returns the integral of y over the rectangle’s interior.

property moment_yy

Returns the integral of y*y over the rectangle’s interior.

move(offset)

Moves the Rect by a given offset vector.

property shapely

Shapely representation for fast intersection operations.

property signed_area

Returns the signed area of the rectangle.

to_json()

Returns a list [min_x, min_y, max_x, max_y].

to_tensor()

Returns a tensor [min_x, min_y, max_x, max_y] representing the rect .

property w

width

property x

left, same as min_x.

property y

top, same as min_y.