|
|
Sorry, generating meshes from splines is not trivial, especially when you
have a parametric surface with u = "clock value" and v going around the
spline. The issue comes from finding a consistent "normal" vector to the
spline to start the mesh circle. I tried using the standard normal to the
spline (2nd derivative) for this and the results were at best inconsistent,
often leading to a serious case of the "twisties" where the actual radius is
much less than planned.
What I ended up doing was taking an arbitrary normal vector to start with,
then projecting the unit normal point onto the normal plane at the next
point:
<code>
#macro pnt(i, j, p, q, spl)
#if (j=vMin) // Calculate only at start of circle
#declare _st = spl(i); // New start point
#declare _dr = vnormalize(spl(i+1e-4)-spl(i-1e-4)); // New direction
vector
#if (i=uMin) // Initialization, arbitrary start normal
#local nrm = vcross(_dr,z);
#if (vlength(nrm)<.1) #local nrm = vcross(_dr,x); #end // Insurance
against degenerate cross product
#declare _norm = vnormalize(nrm);
#else
#local bas = _ost+_onrm; // get normal offset at old point
#local prj = (bas+_dr*(vdot(_dr,_st)-vdot(_dr,bas))); // project onto
plane at new point, normal as new direction
#declare _norm = vnormalize(prj-_st); // new normal traces from new point
to projected point
#end
#declare _onrm = _norm; // save old normal vector
#declare _ost = _st; // save old point
#declare _ortho = vcross(_dr,_norm); // orthonormal vector
#end
#local mrad = rad1*i+rad0*(uMax-i);
#local irad = 0.85 + 0.10*sin(j*5) + q*.05;
#local mdir = _norm*cos(j)+_ortho*sin(j);
_st+mdir*mrad*irad
#end
</code>
For the end caps (i = uMin || i = uMax) just set the radius to 0. If you
want flat rather than conical ends then set the endpoints just outside the
spline's range and push the endpoints back.
"Rune" <run### [at] runevisioncom> wrote in message
news:40a87c8b$1@news.povray.org...
> ABX wrote:
> > Rune wrote:
> >> ABX wrote:
> >>> As mentioned, you still can create lathe-like
> >>> mesh from spline.
> >>
> >> Is there some macro for this purpose?
> >
> > http://members.home.nl/seedseven/#lathe
> >
> >> The sides of the prism are trivial
> >> of course, but the caps not quite as trivial...
> >
> > It is even less trivial for all splines when
> > written in C++
>
> I think I must have been tired. In this whole thread only lathes and
> sors have been mentioned, but in my head I was thinking prisms (which
> are also based on splines). It is prisms that I think are non-trivial to
> generate with a macro due to the end caps...
>
> Rune
> --
> 3D images and anims, include files, tutorials and more:
> rune|vision: http://runevision.com **updated Apr 27**
> POV-Ray Ring: http://webring.povray.co.uk
>
>
Post a reply to this message
|
|