|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
> I have looked into signed distance functions of meshes, and people have worked
> out how to do that, so it may very likely be possible.
>
first you'd have to make sure the winding per triangle/polygon is consisten
cw/ccw.
then you can look at the "general winding number" to find wheter inside or
outside the mesh and to find whether the mesh is closed.
If winding number is 1, inside mesh, else if 0 outside mesh, else mesh not
closed
The winding number should be consisten for all polygons, else the mesh is not
closed.
This can then turned into a signed distance value / field (SDF): distance = + /
- distance] negative distance = inside.
triangle [v1, v2, v3]
p = test point
a = v1 - p
b = v2 - p
c = v3 - p
num = dot(a, cross(b, c)) (the scalar triple product)
den = |a||b||c| + dot(a,b)*|c| + dot(b,c)*|a| + dot(c,a)*|b|
omega_triangle = 2 * atan2(num, den )
omega_mesh = sum(omega_triangle)
generalised winding number = omega_mesh / 4*PI
if you're shure th mesh is closed you can fall back to trace and count
intersections to determine inside/outside.
Any one ever peeked at the code of OpenScad? They have this or similar
routinely,
ingo
Post a reply to this message
|
 |