xdesign.geometry
¶
Functions:
Point (x) |
A point in ND cartesian space. |
Superellipse (center, a, b, n) |
Superellipse in 2-D cartesian space. |
Ellipse (center, a, b) |
Ellipse in 2-D cartesian space. |
Circle (center, radius) |
Circle in 2-D cartesian space. |
Line (p1, p2) |
Line in 2-D cartesian space. |
Triangle (p1, p2, p3) |
Triangle in 2-D cartesian space. |
Rectangle (p1, p2, p3, p4) |
Rectangle in 2-D cartesian space. |
Square (center, side_length) |
Square in 2-D cartesian space. |
-
class
xdesign.geometry.
Entity
[source]¶ Bases:
object
Base class for all geometric entities. All geometric entities should have these methods.
-
contains
(point)[source]¶ Returns True if the point(s) is within the bounds of the entity. point is either a Point or an N points listed as an NxD array.
-
dim
¶ The dimensionality of the entity
-
rotate
(theta, point=None, axis=None)[source]¶ Rotate entity around an axis which passes through a point by theta radians.
-
-
class
xdesign.geometry.
Point
(x)[source]¶ Bases:
xdesign.geometry.Entity
A point in ND cartesian space.
-
_x
¶ 1darray
ND coordinates of the point.
-
x
¶ scalar
dimension 0 of the point.
-
y
¶ scalar
dimension 1 of the point.
-
z
¶ scalar
dimension 2 of the point.
-
norm
¶ scalar
The L2/euclidian norm of the point.
-
dim
¶
-
norm
Reference: http://stackoverflow.com/a/23576322
-
scale
(vector)[source]¶ Scale entity in each dimension according to vector. Scaling is centered on the origin.
-
x
-
y
-
z
-
-
class
xdesign.geometry.
Circle
(center, radius)[source]¶ Bases:
xdesign.geometry.Curve
Circle in 2-D cartesian space.
-
center
¶ Point
Defines the center point of the circle.
-
radius
¶ scalar
Radius of the circle.
-
area
¶ Return area.
-
circumference
¶ Return circumference.
-
diameter
¶ Return diameter.
-
list
¶ Return list representation for saving to files.
-
patch
¶
-
-
class
xdesign.geometry.
Line
(p1, p2)[source]¶ Bases:
xdesign.geometry.LinearEntity
Line in 2-D cartesian space.
It is defined by two distinct points.
-
p1
¶ Point
-
p2
¶ Point
-
distance
(other)[source]¶ Return the closest distance between entities. REF: http://geomalgorithms.com/a02-_lines.html
-
standard
¶ Returns coeffients for the first N-1 standard equation coefficients. The Nth is returned separately.
-
xintercept
¶ Return the x-intercept.
-
yintercept
¶ Return the y-intercept.
-
-
class
xdesign.geometry.
Polygon
(vertices)[source]¶ Bases:
xdesign.geometry.Entity
A convex polygon in 2-D cartesian space.
It is defined by a number of distinct points.
-
vertices
¶ sequence of Points
-
area
¶ Return the area of the entity.
-
bounds
¶ Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
-
half_space
¶
-
list
¶ Return list representation.
-
numpy
¶ Return Numpy representation.
-
numverts
¶
-
patch
¶
-
perimeter
¶ Return the perimeter of the entity.
-
-
class
xdesign.geometry.
Triangle
(p1, p2, p3)[source]¶ Bases:
xdesign.geometry.Polygon
Triangle in 2-D cartesian space.
It is defined by three distinct points.
-
area
¶
-
center
¶
-
-
class
xdesign.geometry.
Rectangle
(p1, p2, p3, p4)[source]¶ Bases:
xdesign.geometry.Polygon
Rectangle in 2-D cartesian space.
It is defined by four distinct points.
-
area
¶
-
center
¶
-
-
class
xdesign.geometry.
Square
(center, side_length)[source]¶ Bases:
xdesign.geometry.Rectangle
Square in 2-D cartesian space.
It is defined by a center and a side length.