-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from pygae/point_processing
Point processing
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
import scipy.spatial | ||
import numpy as np | ||
from .. import MVArray | ||
|
||
|
||
class GAConvexHull(scipy.spatial.ConvexHull): | ||
""" | ||
Uses scipy to produce an n_dims dimensional convex hull of the input points | ||
if hull_dims is not provided it will use the dimension of the input layout | ||
if hull_dims is provided it will use the first hull_dims basis vectors | ||
""" | ||
def __init__(self, points, hull_dims=None, incremental=False, qhull_options=None): | ||
|
||
# Prep the GA specific stuff | ||
self.layout = points[0].layout | ||
if hull_dims is None: | ||
hull_dims = self.layout.dims | ||
self.algebra_dims = self.layout.dims | ||
self.hull_dims = hull_dims | ||
point_array = np.array([p.value[1:hull_dims+1] for p in points]) | ||
|
||
# Run the superclass constructor | ||
scipy.spatial.ConvexHull.__init__(self, point_array, | ||
incremental=incremental, | ||
qhull_options=qhull_options) | ||
# Keep the GAversion | ||
self.GApoints = points | ||
|
||
def conformal_facets(self): | ||
""" | ||
Returns the list of conformal points in each facet | ||
""" | ||
if self.layout.isconformal: | ||
return [[self.GApoints[i] for i in s] for s in self.simplices] | ||
else: | ||
raise ValueError('Input points do not seem to be from a conformal algebra') | ||
|
||
def conformal_rounds(self): | ||
""" | ||
Returns the conformal rounds made of the wedge | ||
product of the edge simplices | ||
""" | ||
if self.layout.isconformal: | ||
return [MVArray([self.GApoints[i] for i in s]).op().normal() for s in self.simplices] | ||
else: | ||
raise ValueError('Input points do not seem to be from a conformal algebra') | ||
|
||
def conformal_flats(self): | ||
""" | ||
Returns the conformal flats made of the wedge | ||
product of the edge simplices with einf | ||
""" | ||
if self.layout.isconformal: | ||
return [(r^self.layout.einf).normal() for r in self.conformal_rounds()] | ||
else: | ||
raise ValueError('Input points do not seem to be from a conformal algebra') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters