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=(o_x, o_y)\) and direction vectors \(\mathbf{u}=(u_x, u_y)\) and \(\mathbf{v}=(v_x, v_y)\).
Parameters: Notes
Parallelogram
represents the bounded region \(\left \{o+\lambda_1\mathbf{u}+\lambda_2\mathbf{v}\in R^2 |0\le\lambda_i\le 1\right\}\), where \(\mathbf{u}\) and \(\mathbf{v}\) have to be linearly independent.Calling
Paralleogram
with no parameters is equivalent toParallelogram
(o=[0, 0], u=[1, 0], v=[1, 1])
Attributes
area
Paralleogram
area, \(A=|\mathbf{u}\times\mathbf{v}|\).bounding_box
Bounding Cuboid
.center
Alias for centroid
.centroid
Paralleogram centroid, \((c_x, c_y)\). fmtstr
Format string. measure
Alias for area
, which is the measure of a 2D geometric region.ndim
Return the dimensions. o
2D point coordinates \((o_x, o_y)\) of origin. pmax
Point
at maximum extent.pmin
Point
at minimum extent.u
2D direction vector \(\mathbf{u}=(u_x, u_y)\), with origin o
v
2D direction vector \(\mathbf{v}=(v_x, v_y)\), with origin o
Methods
center_centroid
()Center centroid
on origin.contains
(point)Test region membership of point
inParallelogram
.get_points
()Return list of points from GeometricRegion.points
andGeometricRegion.vectors
rotate
(**kwargs)Rotate GeometricRegion
points
andvectors
.todict
()Returns a dict
of theParalleogram
constructor parameters.translate
(t[, fix_anchor_points])Translate GeometricRegion
points
andvectors
byVector
t
.Attributes Summary
area
Paralleogram
area, \(A=|\mathbf{u}\times\mathbf{v}|\).centroid
Paralleogram centroid, \((c_x, c_y)\). o
2D point coordinates \((o_x, o_y)\) of origin. u
2D direction vector \(\mathbf{u}=(u_x, u_y)\), with origin o
v
2D direction vector \(\mathbf{v}=(v_x, v_y)\), with origin o
Methods Summary
contains
(point)Test region membership of point
inParallelogram
.todict
()Returns a dict
of theParalleogram
constructor parameters.Attributes Documentation
-
area
¶ Paralleogram
area, \(A=|\mathbf{u}\times\mathbf{v}|\).Computed as:
\[A = |\mathbf{u}\times\mathbf{v}|\]
-
centroid
¶ Paralleogram centroid, \((c_x, c_y)\).
Computed as the 2D point \((c_x, c_y)\) with coordinates:
\[c_x = o_x + \frac{u_x + v_x}{2}\]\[c_y = o_y + \frac{u_y + v_y}{2}\]where \((o_x, o_y)\), \((u_x, u_y)\), and \((v_x, v_y)\) are the \((x, y)\) coordinates of the origin \(o\) and \((x, y)\) components of the direction vectors \(\mathbf{u}\) and \(\mathbf{v}\), respectively.
Returns: 2D Point
of centroid.Return type: Point
-
o
¶ 2D point coordinates \((o_x, o_y)\) of origin.
Returns: 2D Point
coordinates \((o_x, o_y)\) of origin.Return type: Point
-
u
¶ 2D direction vector \(\mathbf{u}=(u_x, u_y)\), with origin
o
-
v
¶ 2D direction vector \(\mathbf{v}=(v_x, v_y)\), with origin
o
Methods Documentation
-
contains
(point)[source] [edit on github][source]¶ Test region membership of
point
inParallelogram
.Parameters: point (array_like) – Returns: True
ifpoint
is withinParalleogram
,False
otherwiseReturn type: bool
Notes
A
point
\((p_x, p_y)\) is within the bounded region of a parallelogram with origin \((o_x, o_y)\) and direction vectors \(\mathbf{u}=(u_x, u_y)\) and \(\mathbf{v}=(v_x, v_y)\) if the following is true:\[0\le\frac{(p_y - o_y) v_x + (o_x - p_x) v_y}{u_y v_x - u_x v_y} \le 1 \land 0\le\frac{(p_y - o_y) u_x + (o_x - p_x) u_y}{u_x v_y - u_y v_x} \le 1\]
-
todict
()[source] [edit on github][source]¶ Returns a
dict
of theParalleogram
constructor parameters.
-