[Sidefx-houdini-list] fracturing a grid with polygonal curves?
Mario Marengo
mario at axyzfx.com
Fri Aug 24 18:15:09 EDT 2007
Just thinking out loud here, but it seems that you really only need to solve
how to determine if the point (5) is within the valid region enclosed by the
curves (4). Finding the actual grid polygon is trivial. Here's one idea that
comes to mind:
* For each of the curves in (4):
1. Find the parametric u (Pu) and position (Pnear) along the curve with the
minimum distance to the point in (5) (which I'll call "X") using the
pointdist() and primuv() expression functions.
2. Derive a perpendicular for the tangent to the curve at Pnear. You get the
tangent (Ptan) with the primduv() function, and trivially define a
perpendicular as {Ptan.z,0,-Ptan.x} or {-Ptan.z,0,Ptan.x} depending on
whether the curve should "Keep Inside" or "Keep Outside" (which are very
loose concepts here, but could be made into an attribute of these slicing
curves). The perpendicular (Pperp) also assumes that we're working strictly
on the XZ plane, of course.
3. Now you can test whether P is "inside" the half-space defined by the
current curve by testing for "dot(Pnear-X,Pperp)<0". If it passes the test,
continue, else break and stop since X is not within the valid region of the
grid. Note that this test implicitly interprets the curves as extending
indefinitely along the tangent at each endpoint.
* End_For
If X passes the test for all curves, then extract the grid's polygon at X
using, again, the pointdist() function with a primitive number value of -1
and a return type value of 3.
So the whole thing would reduce to (in pseudo-code):
int passed = 0;
for curve c in "curves_sop" {
Pu = pointdist("add_sop",0,"curves_sop",c,1);
Pnear = primuv("curves_sop",c,"P",[0,1,2],Pu,0);
Ptan = primduv("curves_sop",c,"P",[0,1,2],Pu,0,1,0);
Pperp = KeepInside ? {-Ptan.z,0,Ptan.x} : {Ptan.z,0,-Ptan.x};
if(dot(Pnear-X,Pperp)>=0) { passed=0; break; }
passed ++;
}
if(passed)
grid_prim = pointdist("add_sop",0,"grid_sop",-1,3);
else
grid_prim = -1;
Not sure but you might be able to construct the loop with stamping...
Anyway, all of the above is untested.
Good luck!
--
......................................................................
Mario Marengo mailto:mario at axyzfx.com
AXYZ ANIMATION http://www.axyzfx.com
......................................................................
More information about the Sidefx-houdini-list
mailing list