diff --git a/pybie2d/boundaries/global_smooth_boundary/global_smooth_boundary.py b/pybie2d/boundaries/global_smooth_boundary/global_smooth_boundary.py index b2e594e..3eefc1d 100644 --- a/pybie2d/boundaries/global_smooth_boundary/global_smooth_boundary.py +++ b/pybie2d/boundaries/global_smooth_boundary/global_smooth_boundary.py @@ -1,5 +1,6 @@ import numpy as np import scipy as sp +import matplotlib as mpl import scipy.signal import warnings import os @@ -74,6 +75,7 @@ def __init__(self, x=None, y=None, c=None): self.max_h = np.max(self.weights) self.area = self.dt*np.sum(self.x*self.cp.imag) self.perimeter = self.dt*np.sum(self.speed) + self.poly= mpl.path.Path(np.column_stack([self.x, self.y])) self.defined_modules = [ 'Laplace_SLP_Self_Kress', 'Stokes_SLP_Self_Kress', @@ -193,15 +195,49 @@ def Get_Close_Corrector(self, kernel, *args, **kwargs): ######################### #### Private Methods #### ######################### - - def _test_inside_point(self, candidate, eps=1e-10): + + # THIS ROUTINE IS NOT RELIABLE + #def _test_inside_point(self, candidate, eps=1e-10): + # """ + # Test whether the provided or generated inside point is acceptable + # returns True if the point is okay, False if its not + # """ + # test_value = np.sum(self.complex_weights/(self.c-candidate)) + # return np.abs(test_value - 2.0j*np.pi) < eps + ## end _test_inside_point function + + # THIS ROUTINE IS RELIABLE AND INDEPENDENT OF MATPLOTLIB + #def _test_inside_point(self, candidate, eps=1e-12): + # """ + # Test whether the provided or generated inside point is acceptable + # returns True if the point is okay, False if its not + # Algorithm: point in polygon (the points in self.c are interpreted as closed polygon), + # the sum of angles between the vectors from the point (candidate) to two consecutive points on the boundary # + # polygon. the sum is equal 2pi only if the point lies inside. Safe way to compute the angle is using arctan2 of #(a x b)/(a.b). + # """ + # a=self.c-candidate + # if (np.any(np.abs(a)