Hull
ConvexHull(pts)
¶
A class to handle convex-hull calculations.
seg_dict
is a dictionary object that contains information about
segments within the convex hull.
- The keys are 2x3 tuples, which represent two ends of a segment in space.
- The values of
seg_dict
are the number of times a segment has been part of a triangle, either1
or2
.0
times would mean that the segment doesn't exist in the dictionary yet.
Initializes the ConvexHull class.
hull = self.gift_wrapping_3d(akl_toussaint_pts)
¶
akl_toussaint(points)
¶
The Akl-Toussaint Heuristic.
Given a set of points, this definition will create an octahedron whose corners are the extremes in x, y, and z directions. Every point within this octahedron will be removed because they are not part of the convex hull. This causes any expected running time for a convex hull algorithm to be reduced to linear time.
PARAMETER | DESCRIPTION |
---|---|
|
An nx3 array of x,y,z coordinates.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
NDArray[float64]
|
All members of original set of points that fall outside the Akl-Toussaint octahedron. |
get_seg_dict_num(seg_dict, seg_index)
¶
This function looks up and returns the value of a seg_index from seg_dict
.
PARAMETER | DESCRIPTION |
---|---|
|
The dictionary of segment 2x3 tuples as keys, integers as values.
TYPE:
|
|
the key of the dictionary member we are going to retrieve
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int
|
If |
gift_wrapping_3d(raw_points)
¶
Gift wrapping for 3d convex hull.
PARAMETER | DESCRIPTION |
---|---|
|
A nx3 array of points, where each row corresponds to an x,y,z point coordinate.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[NDArray[float64]]
|
A convex hull represented by a list of triangles. Each triangle is a 3x3 array, where each row is an x,y,z coordinate in space. The 3 rows describe the location of the 3 corners of the triangle. Each of the 3 points are arranged so that a cross product will point outwards from the hull. |
increment_seg_dict(seg_dict, seg_index)
¶
This function increments the values within seg_dict, or initiates them if they dont exist yet.
PARAMETER | DESCRIPTION |
---|---|
|
the dictionary of segment 2x3 tuples as keys, integers as values.
TYPE:
|
|
the key of the dictionary member we are going to increment.
TYPE:
|
inside_hull(our_point)
¶
Determines if a point is inside the hull
PARAMETER | DESCRIPTION |
---|---|
|
An x,y,z array
|
RETURNS | DESCRIPTION |
---|---|
A boolean, True if the point is inside the hull, False otherwise. |
outside_hull(point, triangles, epsilon=1e-05)
¶
Given the hull as defined by a list of triangles, this definition will return whether a point is within these or not.
PARAMETER | DESCRIPTION |
---|---|
|
an x,y,z array that is being tested to see whether it exists inside the hull or not.
TYPE:
|
|
a list of triangles that define the hull.
TYPE:
|
|
needed for imprecisions in the floating-point operations.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if our_point exists outside of the hull, False otherwise |