sxyu / sdf

Parallelized triangle mesh --> continuous signed distance field on CPU
BSD 2-Clause "Simplified" License
430 stars 39 forks source link

I met with erratic results #5

Open zb12138 opened 2 years ago

zb12138 commented 2 years ago

I encounter unstable results when I run Python code. Is there any randomness to this method? This is my code:

import numpy as np
from pysdf import SDF
import trimesh
o = trimesh.load('aa.obj')
o.vertices = o.vertices - o.vertices.min()
resolution = 100

tick = np.expand_dims(np.linspace((o.vertices).min(),(o.vertices).max(),resolution),1)
[x,y,z] = np.meshgrid(tick,tick,tick)
queryPoint = np.c_[x.reshape(-1),y.reshape(-1),z.reshape(-1)]

f = SDF(o.vertices, o.faces)
sdf0 = f(queryPoint)
f1 = SDF(o.vertices, o.faces)
sdf1 = f1(queryPoint)
print((sdf0 - sdf1).max())

environment: Intel(R) Core(TM) i5-9500 CPU; Windows 10; pyhton 3.7.9; No GPUs

expected output: 0 actual output: 37.03153 (stochastic)

Can you provide a method without randomness? Thank you!

omaralvarez commented 7 months ago

I have the same issue, is there a way to obtain always same results? Some points randomly have incorrect distances.

I have non watertight mesh, could that be the cause?