POV-Ray : Newsgroups : povray.general : 2D function to 3D tube : Re: 2D function to 3D tube Server Time
6 May 2024 04:07:31 EDT (-0400)
  Re: 2D function to 3D tube  
From: Tor Olav Kristensen
Date: 25 Dec 2022 00:00:00
Message: <web.63a7d8be560d6168a47c74b589db30a9@news.povray.org>
"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.
> >
> > Yeah - not sure if that's the math or the macro.
> > It seems to be right at the beginning of the curve, so maybe instead of going
> > from 0 - 2pi, maybe start at pi/180 and see if that trims off the cruft.
> >...
>
> 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.
Here's a cleaned up version:

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro SimpleMesh(FnX, FnY, FnZ, MinU, MaxU, MinV, MaxV, SizeI, SizeJ)

    #local LastI = SizeI - 1;
    #local LastJ = SizeJ - 1;
    #local Vertices = array[SizeI][SizeJ];
    #local SpanU = MaxU - MinU;
    #local SpanV = MaxV - MinV;
    #for (I, 0, LastI)
        #local U = MinU + I/LastI*SpanU;
        #for (J, 0, LastJ)
            #local V = MinV + J/LastJ*SpanV;
            #local Vertices[I][J] =
                <FnX(U, V), FnY(U, V), FnZ(U, V)>
            ;
        #end // for
    #end // for

    mesh {
        #for (I, 0, LastI - 1)
            #for (J, 0, LastJ - 1)
                #local p00 = Vertices[I  ][J  ];
                #local p01 = Vertices[I  ][J+1];
                #local p10 = Vertices[I+1][J  ];
                #local p11 = Vertices[I+1][J+1];
                triangle { p00, p10, p11 }
                triangle { p11, p01, p00 }
            #end // for
        #end // for
    }

#end // macro SimpleMesh

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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