POV-Ray : Newsgroups : povray.pov4.discussion.general : Suggest v4.0 sor{} fixes / changes. (yuqk R20 v0.6.14.0) : Re: Suggest v4.0 sor{} fixes / changes. (yuqk R20 v0.6.14.0) Server Time
3 Oct 2025 01:37:50 EDT (-0400)
  Re: Suggest v4.0 sor{} fixes / changes. (yuqk R20 v0.6.14.0)  
From: ingo
Date: 23 Sep 2025 13:45:00
Message: <web.68d2db8c736a032617bac71e8ffb8ce3@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.