Parallelogram¶
-
class
sknano.core.geometric_regions.Parallelogram(o=None, u=None, v=None)[source] [edit on github][source]¶ Bases:
sknano.core.geometric_regions.Geometric2DRegionGeometric2DRegionfor 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
Parallelogramrepresents 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
Paralleogramwith no parameters is equivalent toParallelogram(o=[0, 0], u=[1, 0], v=[1, 1])Attributes
areaParalleogramarea, \(A=|\mathbf{u}\times\mathbf{v}|\).bounding_boxBounding Cuboid.centerAlias for centroid.centroidParalleogram centroid, \((c_x, c_y)\). fmtstrFormat string. measureAlias for area, which is the measure of a 2D geometric region.ndimReturn the dimensions. o2D point coordinates \((o_x, o_y)\) of origin. pmaxPointat maximum extent.pminPointat minimum extent.u2D direction vector \(\mathbf{u}=(u_x, u_y)\), with origin ov2D direction vector \(\mathbf{v}=(v_x, v_y)\), with origin oMethods
center_centroid()Center centroidon origin.contains(point)Test region membership of pointinParallelogram.get_points()Return list of points from GeometricRegion.pointsandGeometricRegion.vectorsrotate(**kwargs)Rotate GeometricRegionpointsandvectors.todict()Returns a dictof theParalleogramconstructor parameters.translate(t[, fix_anchor_points])Translate GeometricRegionpointsandvectorsbyVectort.Attributes Summary
areaParalleogramarea, \(A=|\mathbf{u}\times\mathbf{v}|\).centroidParalleogram centroid, \((c_x, c_y)\). o2D point coordinates \((o_x, o_y)\) of origin. u2D direction vector \(\mathbf{u}=(u_x, u_y)\), with origin ov2D direction vector \(\mathbf{v}=(v_x, v_y)\), with origin oMethods Summary
contains(point)Test region membership of pointinParallelogram.todict()Returns a dictof theParalleogramconstructor parameters.Attributes Documentation
-
area¶ Paralleogramarea, \(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 Pointof centroid.Return type: Point
-
o¶ 2D point coordinates \((o_x, o_y)\) of origin.
Returns: 2D Pointcoordinates \((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
pointinParallelogram.Parameters: point (array_like) – Returns: Trueifpointis withinParalleogram,FalseotherwiseReturn type: boolNotes
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
dictof theParalleogramconstructor parameters.
-