made a simplex class, going to move this into the face class to simplify
This commit is contained in:
+1
-1
@@ -67,7 +67,7 @@ def get_phis_3D(X, r):
|
||||
def qlinear(X, R, q):
|
||||
"""
|
||||
this calculates the linear portion of q from X to r
|
||||
|
||||
|
||||
also, this is baker eq 3
|
||||
|
||||
X = destination point
|
||||
|
||||
+37
-1
@@ -7,7 +7,7 @@ from collections import defaultdict
|
||||
import numpy as np
|
||||
import scipy.spatial
|
||||
|
||||
from baker import run_baker
|
||||
from baker import run_baker, get_phis
|
||||
from tools import exact_func
|
||||
from smcqdelaunay import *
|
||||
|
||||
@@ -32,6 +32,28 @@ class face(object):
|
||||
", ".join(neighbors)
|
||||
)
|
||||
|
||||
|
||||
|
||||
class simplex(object):
|
||||
def __init__(self, points):
|
||||
self.R = points
|
||||
|
||||
def contains(self, X):
|
||||
phis = get_phis(X, self.R)
|
||||
|
||||
r = True
|
||||
if [i for i in phis if i < 0.0]:
|
||||
r = False
|
||||
return r
|
||||
|
||||
def __str__(self):
|
||||
print type(self.R)
|
||||
return "simplex: %d: [%s]" % (len(self.R), ", ".join([str(i) for i in self.R]),)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class grid(object):
|
||||
facet_re = re.compile(r'''
|
||||
-\s+(?P<facet>f\d+).*?
|
||||
@@ -89,6 +111,20 @@ class grid(object):
|
||||
(R, S) = self.get_simplex_and_nearest_points(X)
|
||||
return run_baker(X, R, S)
|
||||
|
||||
def get_points_conn(self, X):
|
||||
if not self.faces:
|
||||
self.construct_connectivity()
|
||||
|
||||
(dist, indicies) = self.tree.query(X, 3)
|
||||
print dist, indicies, [(self.points[i][0], self.points[i][1]) for i in indicies]
|
||||
print [i.name for i in self.facets_for_point[indicies[0]]]
|
||||
print self.facets_for_point[indicies[0]]
|
||||
|
||||
smplx = simplex([self.points[i] for i in indicies])
|
||||
|
||||
if not smplx.contains(X):
|
||||
raise AssertionError('simplex should contain point')
|
||||
|
||||
def construct_connectivity(self):
|
||||
"""
|
||||
a call to this method prepares the internal connectivity structure.
|
||||
|
||||
Reference in New Issue
Block a user