xdesign.geometry
¶
Define geometric objects for compuational geometry operations.
Zero dimensional entities¶
Define zero dimensional geometric entities.
Classes:
Point (x) 
Define a point in ND cartesian space. 

class
xdesign.geometry.point.
Point
(x)[source]¶ Bases:
xdesign.geometry.entity.Entity
Define a point in ND cartesian space.
Parameters: x ( ndarray
,list
) – ND coordinates of the point.Raises: TypeError
– If x is not a list or ndarray.
contains
(other)[source]¶ Return wether the other is within the bounds of the Point.
Points can only contain other Points.

norm
¶ Euclidian (L2) norm of the vector to the point.

scale
(vector)[source]¶ SScale the ambient space in each dimension according to vector.
Scaling is centered on the origin.

x
¶ Dimension 0 of the point.

y
¶ Dimension 1 of the point.

z
¶ Dimension 2 of the point.


xdesign.geometry.point.
calc_standard
(A)[source]¶ Return the standard equation for the rowwise points in A.
The coefficents (c_{0}*x + … = c_{1}) describe the hyperplane defined by the rowwise Ndimensional points A.
Parameters: A ( np.array
(…, N, N)) – Each row is an Ndimensional point on the plane.Returns:  c0 (
np.array
(…, N)) – The first N coeffients for the hyperplane  c1 (
np.array
(…, 1)) – The last coefficient for the hyperplane
 c0 (

xdesign.geometry.point.
rotated
(self, theta, center=None, axis=None)[source]¶ Rotates theta radians around an axis.
One dimensional entities¶
Define one dimensional geometric entities.
Classes:
Line (p1, p2) 
Line in 2D cartesian space. 
Segment (p1, p2) 
Defines a finite line segment from two unique points. 

class
xdesign.geometry.line.
Line
(p1, p2)[source]¶ Bases:
xdesign.geometry.line.LinearEntity
Line in 2D cartesian space.
The constructor takes two unique
Point
.
standard
¶ Returns coeffients for the first N1 standard equation coefficients. The Nth is returned separately.

xintercept
¶ Return the xintercept.

yintercept
¶ Return the yintercept.

Two dimensional entities¶
Define two dimensional geometric entities.
Classes:
Curve (center) 
The base class for closed manifolds defined by a single equation. 
Circle (center, radius[, sign]) 
Circle in 2D cartesian space. 
Polygon (vertices[, sign]) 
A convex polygon in 2D cartesian space. 
Triangle (p1, p2, p3) 
Triangle in 2D cartesian space. 
Rectangle (center, side_lengths) 
Rectangle in 2D cartesian space. 
Square (center[, side_length, radius]) 
Square in 2D cartesian space. 
Mesh ([obj, faces]) 
A collection of Entities 

class
xdesign.geometry.area.
Curve
(center)[source]¶ Bases:
xdesign.geometry.entity.Entity
The base class for closed manifolds defined by a single equation. e.g.
Circle
,Sphere
, orTorus
.

class
xdesign.geometry.area.
Circle
(center, radius, sign=1)[source]¶ Bases:
xdesign.geometry.area.Curve
Circle in 2D cartesian space.

radius
¶ The radius of the circle.
Type: scalar

area
¶ Return the area.

bounding_box
¶ Return the axisaligned bounding box as two numpy vectors.

circumference
¶ Returns the circumference.

contains
(other)[source]¶ Return whether other is a proper subset.
Return one boolean for all geometric entities. Return an array of boolean for array input.

diameter
¶ Returns the diameter.

list
¶ Return list representation for saving to files.

patch
¶ Returns a matplotlib patch.


class
xdesign.geometry.area.
Polygon
(vertices, sign=1)[source]¶ Bases:
xdesign.geometry.entity.Entity
A convex polygon in 2D cartesian space.
It is defined by a number of distinct vertices of class
Point
. Superclasses includeSquare
,Triangle
, etc.
vertices
¶ Type: List of Points

area
= <MagicMock name='mock()' id='140706171286752'>¶

bounding_box
¶ Return the axisaligned bounding box as two numpy vectors.

bounds
¶ Returns a 4tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the Polygon.

center
= <MagicMock name='mock()' id='140706171286752'>¶

edges
¶ Return a list of lines connecting the points of the Polygon.

half_space
= <MagicMock name='mock()' id='140706171286752'>¶

list
¶ Return list representation.

numpy
¶ Return Numpy representation.

numverts
¶

patch
¶ Returns a matplotlib patch.

perimeter
= <MagicMock name='mock()' id='140706171286752'>¶

radius
= <MagicMock name='mock()' id='140706171286752'>¶


class
xdesign.geometry.area.
Triangle
(p1, p2, p3)[source]¶ Bases:
xdesign.geometry.area.Polygon
Triangle in 2D cartesian space.
It is defined by three distinct points.

area
= <MagicMock name='mock()' id='140706171286752'>¶

center
= <MagicMock name='mock()' id='140706171286752'>¶


class
xdesign.geometry.area.
Rectangle
(center, side_lengths)[source]¶ Bases:
xdesign.geometry.area.Polygon
Rectangle in 2D cartesian space.
Defined by a point and a vector to enforce perpendicular sides.

side_lengths
¶ The lengths of the sides
Type: array

area
= <MagicMock name='mock()' id='140706171286752'>¶


class
xdesign.geometry.area.
Square
(center, side_length=None, radius=None)[source]¶ Bases:
xdesign.geometry.area.Rectangle
Square in 2D cartesian space.
Defined by a point and a length to enforce perpendicular sides.

class
xdesign.geometry.area.
Mesh
(obj=None, faces=[])[source]¶ Bases:
xdesign.geometry.entity.Entity
A collection of Entities

bounding_box
¶ Return the axisaligned bounding box as two numpy vectors.

center
¶

contains
(other)[source]¶ Return whether this Mesh contains other.
FOR ALL x, THERE EXISTS a face of the Mesh that contains x AND (ALL cut outs that contain x or THERE DOES NOT EXIST a cut out).

patch
¶

Intersect¶
Define algorithms to support intersection calculation.
Functions:
clip_SH (clipEdges, polygon) 
Clip a polygon using the SutherlandHodgeman algorithm. 
halfspacecirc (d, r) 
Return the area of intersection between a circle and halfplane. 

xdesign.geometry.intersect.
clip_SH
(clipEdges, polygon)[source]¶ Clip a polygon using the SutherlandHodgeman algorithm.
Parameters:  clipEdges [[A, b], …] – halfspaces defined by coefficients
 polygon

xdesign.geometry.intersect.
halfspacecirc
(d, r)[source]¶ Return the area of intersection between a circle and halfplane.
Returns the smaller fraction of a circle split by a line d units away from the center of the circle.
Parameters:  d (scalar) – The distance from the line to the center of the circle
 r (scalar) – The radius of the circle
Returns:  f (scalar) – The proportion of the circle in the smaller halfspace
 Reference
 ———
 Glassner, A. S. (Ed.). (2013). Graphics gems. Elsevier.