Parallelogram

class sknano.core.geometric_regions.Parallelogram(o=None, u=None, v=None)[source] [edit on github][source]

Bases: sknano.core.geometric_regions.Geometric2DRegion

Geometric2DRegion for a parallelogram.

New in version 0.3.0.

Represents a parallelogram with origin o=(ox,oy) and direction vectors u=(ux,uy) and v=(vx,vy).

Parameters:
  • o (array_like, optional) – Parallelogram origin. If None, it defaults to o=[0, 0].
  • v (u,) – Parallelogram direction vectors stemming from origin o. If None, then the default values are u=[1, 0] and v=[1, 1].

Notes

Parallelogram represents the bounded region {o+λ1u+λ2vR2|0λi1}, where u and v have to be linearly independent.

Calling Paralleogram with no parameters is equivalent to Parallelogram(o=[0, 0], u=[1, 0], v=[1, 1])

Attributes

area Paralleogram area, A=|u×v|.
bounding_box Bounding Cuboid.
center Alias for centroid.
centroid Paralleogram centroid, (cx,cy).
fmtstr Format string.
measure Alias for area, which is the measure of a 2D geometric region.
ndim Return the dimensions.
o 2D point coordinates (ox,oy) of origin.
pmax Point at maximum extent.
pmin Point at minimum extent.
u 2D direction vector u=(ux,uy), with origin o
v 2D direction vector v=(vx,vy), with origin o

Methods

center_centroid() Center centroid on origin.
contains(point) Test region membership of point in Parallelogram.
get_points() Return list of points from GeometricRegion.points and GeometricRegion.vectors
rotate(**kwargs) Rotate GeometricRegion points and vectors.
todict() Returns a dict of the Paralleogram constructor parameters.
translate(t[, fix_anchor_points]) Translate GeometricRegion points and vectors by Vector t.

Attributes Summary

area Paralleogram area, A=|u×v|.
centroid Paralleogram centroid, (cx,cy).
o 2D point coordinates (ox,oy) of origin.
u 2D direction vector u=(ux,uy), with origin o
v 2D direction vector v=(vx,vy), with origin o

Methods Summary

contains(point) Test region membership of point in Parallelogram.
todict() Returns a dict of the Paralleogram constructor parameters.

Attributes Documentation

area

Paralleogram area, A=|u×v|.

Computed as:

A=|u×v|
centroid

Paralleogram centroid, (cx,cy).

Computed as the 2D point (cx,cy) with coordinates:

cx=ox+ux+vx2cy=oy+uy+vy2

where (ox,oy), (ux,uy), and (vx,vy) are the (x,y) coordinates of the origin o and (x,y) components of the direction vectors u and v, respectively.

Returns:2D Point of centroid.
Return type:Point
o

2D point coordinates (ox,oy) of origin.

Returns:2D Point coordinates (ox,oy) of origin.
Return type:Point
u

2D direction vector u=(ux,uy), with origin o

v

2D direction vector v=(vx,vy), with origin o

Methods Documentation

contains(point)[source] [edit on github][source]

Test region membership of point in Parallelogram.

Parameters:point (array_like) –
Returns:True if point is within Paralleogram, False otherwise
Return type:bool

Notes

A point (px,py) is within the bounded region of a parallelogram with origin (ox,oy) and direction vectors u=(ux,uy) and v=(vx,vy) if the following is true:

0(pyoy)vx+(oxpx)vyuyvxuxvy10(pyoy)ux+(oxpx)uyuxvyuyvx1
todict()[source] [edit on github][source]

Returns a dict of the Paralleogram constructor parameters.