POV-Ray : Newsgroups : povray.general : 2D function to 3D tube : Re: 2D function to 3D tube Server Time
10 Jun 2024 18:04:45 EDT (-0400)
  Re: 2D function to 3D tube  
From: Bald Eagle
Date: 25 Dec 2022 16:45:00
Message: <web.63a8c396560d61681f9dae3025979125@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > "Droj" <803### [at] drojde> wrote:
> > >
> > > > > I will try to do some fine tuning as the heart curve still has an
inconsistency
> > > > > where the dip is.


> > My suspicion is that this is caused by a problem with the Paramcalc
> > macro in meshmaker.inc (The SimpleMesh macro in the code below does
> > not seem to have this problem.)
> >
> > The code below also shows an alternative way to make the final
> > functions for the "tube".
> >...
>
> I see now that the SimpleMesh macro is a bit messy.

I haven't gone through any of the edited mesh macro code yet, but did some
simple mesh creation code of my own, and the problem was still in the
calculation of that damned angle Phi.  It's not very well-behaved, and jumps
around a lot, making adjacent sections of mesh "flip" through the central curve
trace.

I played around with it for quite a while, graphing the values of Phi, and
finally came up with this:

#macro Implicit_CalculatePhi (UU, I_Derivative)
 #local Phi = -atan2 (I_Derivative (UU)*UU, abs (UU+E));
 // correct for flipping around x=0
 #local Phi = select ((Phi+pi/2), Phi+pi, Phi);
 #local Phi = select (UU, -Phi, 0, Phi);

 Phi
#end

It keeps Phi as a nice, continuous value between +/-pi

So in the loops, instead of calculating Phi, just use:
#local Phi = Implicit_CalculatePhi (UU, I_Derivative);

And that seems to have eliminated all of the problems I've noticed at x0 <= 0
where there are mins and maxes in the curve.

Hopefully this does the trick.   I have more curves to plot, and then need to
adapt my macros to parametrics and then the polynomial curves.


Post a reply to this message


Attachments:
Download 'tubecurves.png' (183 KB)

Preview of image 'tubecurves.png'
tubecurves.png


 

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