Skip to content

Commit

Permalink
fix cloud of points are plane or line
Browse files Browse the repository at this point in the history
  • Loading branch information
satabol committed Apr 6, 2024
1 parent 8c254b4 commit 6db84ff
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions utils/voronoi3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,15 @@ def cut_cell(start_mesh, sites_delaunay_params, site_idx, spacing, center_of_mas
# select random sites to test are they are tethraeder or 3D?
# If this thethod get wrong answer then not optimal method will be used.
list_sites_for_test_plane = random.sample( range(0, len(sites)), 4)
v0 = Vector(sites[list_sites_for_test_plane[0]])
res = Vector(sites[list_sites_for_test_plane[1]])-v0
for I in range(2,4):
v_I = list_sites_for_test_plane[I]
res = np.cross( res, Vector(sites[v_I])-v0 )
res_norm = np.linalg.norm(res,ord=1)
v0 = Vector(sites[list_sites_for_test_plane[0]])
v1 = Vector(sites[list_sites_for_test_plane[1]])-v0
v2 = Vector(sites[list_sites_for_test_plane[2]])-v0
v3 = Vector(sites[list_sites_for_test_plane[3]])-v0
cross1_v1_v2 = np.cross(v1, v2)
cross2_v1_v3 = np.cross(v1, v3)
cross12 = np.cross(cross1_v1_v2, cross2_v1_v3)

res_norm = np.linalg.norm(cross12,ord=1)
if res_norm>0.1:
are_sites_plane = False
else:
Expand Down

0 comments on commit 6db84ff

Please sign in to comment.