POV-Ray : Newsgroups : povray.general : Help on Splines : Re: Help on Splines Server Time
1 Aug 2024 16:24:19 EDT (-0400)
  Re: Help on Splines  
From: Chrisir
Date: 20 Jul 2005 14:20:01
Message: <web.42de94d39b2676dc869c55d0@news.povray.org>
Hello!

I did check your second posting, only the first yet.


Well, since I'd like
to paint ***a lot*** of U-arcs, the point is too
have ***only one*** line of Code for each U-arc.

One U-arc consists of the spline defintion
and a while-routine to put spheres on that
spline (to get the actual arc).

I therefore build a Macro for the second step
[a while-routine to put spheres on that
spline (to get the actual arc)] as well:

#macro Use_USpline(P1,P2,Height)

        #declare MSpline = USpline(P1,P2,Height)
        #declare TestSphereRadius = 0.02;
        #declare ctr = 0;

        #while (ctr < 1)
          sphere {
            MSpline(ctr), .05
            pigment { rgb <0.5,1,0> }
          }
          #declare ctr = ctr + 0.01;
        #end   // end of while

        ShowPoint(P1)

        ShowPoint(P2)

#end  // end of macro



Now it's possible to have only one line for
one U-arc:
Use_USpline(<-.87,1.05,-.85>, <.64, 1.1,.6>, 0.5)

that's how far i am as for now.

Thanks a lot for your enormous efforts!

Greetings

Chrisir



****
More complete Code:


// ================

// For Test purposes
#macro ShowPoint(P1)

        #declare TestSphereRadius = 0.02;

        // Capped Cylinder, closed [or open ended]
        // cylinder { <END1>, <END2>, RADIUS [open] }
        //  END1 = coord of one end of cylinder
        //  END2 = coord of other end
        // RADIUS = size of cylinder
        // open = if present, cylinder is hollow, else capped

        cylinder {
          <P1.x-0.4,P1.y,P1.z>, <P1.x+0.4,P1.y,P1.z>, TestSphereRadius
          // open
        }


        cylinder {
          <P1.x,P1.y-.4,P1.z>, <P1.x,P1.y+.4,P1.z>, TestSphereRadius
          // open
        }

        cylinder {
          <P1.x,P1.y,P1.z-.4>, <P1.x,P1.y,P1.z+.4>, TestSphereRadius
          // open
        }

#end    // end of macro

// ================

#macro USpline(P1,P2,Height)
  spline {
    cubic_spline
    -1,P1-y
     0,P1
     0.5, (P1+P2/2 + y*Height)
     1,P2
     2,P2-y
  }
#end  // end of macro

#macro Use_USpline(P1,P2,Height)

        #declare MSpline = USpline(P1,P2,Height)
        #declare TestSphereRadius = 0.02;
        #declare ctr = 0;

        #while (ctr < 1)
          sphere {
            MSpline(ctr), .05
            pigment { rgb <0.5,1,0> }
          }
          #declare ctr = ctr + 0.01;
        #end   // end of while

        ShowPoint(P1)

        ShowPoint(P2)

#end  // end of macro

Use_USpline(<-.87,1.05,-.85>, <.64, 1.1,.6>, 0.5)
Use_USpline(<.87,1.5,1.85>, <2.64, 1.1,.6>, 1.5)
Use_USpline(<.87,.05,.85>, <.4, 1.1,.6>, 1.5)


Post a reply to this message

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