|
![](/i/fill.gif) |
"Jim Kress" <nos### [at] kressworks com> wrote in message
news:3d20b74c$1@news.povray.org...
> > 1. The surface is convex at all vertices.
>
> What exactly do you mean by this? For example, if you have a kidney
shaped
> surface, which is a closed surface but curves in and out, does that meet
> your assumption?
>
> Jim
>
That's why I suggested a "local" center to base the assumption on (the
centroid of the subset of points within a certain radius of the target
triangle). Problematic surfaces look more like 3D crescents, the result of
CSG difference of nearly identical spheres, usually separated by a small
translation of the center. The "interior" surface, created by the cutaway
sphere, would be the real issue. Kidneys have but a small region that might
be similarly affected.
A better approach is to weight the contribution of the points by their
distance from the centroid of the triangle. Say you have a list of the
object's vertices V[i] and a triangle <P1, P2, P3> or <I1, I2, I3> if you
are using indexed triangles via mesh2. First you calculate the triangle
centroid:
#local oTri = (P1+P2+P3)/3; // (V[I1], V[I2], V[I3])/3 if indexed
Then you start adding the weights:
#local wgtTotal = 0;
#local pntTotal = <0,0,0>;
#local i = 0;
#while (i<numPoints)
#local pntDist = vlength(V[i]-oTri);
#if (pntDist<wgtThresh)
#local wgtPoint = pow(pntDist, -wgtPower);
#local wgtTotal = wgtTotal + wgtPoint;
#local pntTotal = pntTotal + V[i]*wgtPoint;
#end
#local i = i + 1;
#end
#local oLocal = pntTotal/wgtTotal;
Now you can use this local center to check your triangle:
#local triNorm = vcross(P3-P1, P2-P1); // Again, replace Pn with V[In] if
using indexes
#local triDir = vdot(triNorm. P1-oLocal);
#if (triDir>0) true #else false #end
This is a rather computationally expensive process that scales poorly with
object size/vertex density.
Post a reply to this message
|
![](/i/fill.gif) |