POV-Ray : Newsgroups : povray.binaries.images : SineSpline: help me improve my macro! (13kbbu) : Re: SineSpline: help me improve my macro! (13kbbu) Server Time
2 Oct 2024 16:29:26 EDT (-0400)
  Re: SineSpline: help me improve my macro! (13kbbu)  
From: Greg M  Johnson
Date: 12 Apr 2000 11:14:53
Message: <38F491DF.CBCCF914@my-dejanews.com>
PERFECT!  Publish it.

Tor Olav Kristensen wrote:

> "Greg M. Johnson" wrote:
>
> > I have a new macro to get a moderately smooth transition between points.
>
> Interesting macro!
>
> I have not installed MegaPov on my PC yet, so I can not run your code... :-(
>
> > If anyone thinks this is of any value to humanity, please make it more
> > streamlined, if possible.....
>
> See my try below. (Source code for POV-Ray v3.1)
>
> Tor Olav
>
> mailto:tor### [at] hotmailcom
> http://www.crosswinds.net/~tok/tokrays.html
>
> // ====================================
>
> #version 3.1;
> #include "colors.inc"
>
> #macro sinespline(xgive, ptArray)
>
>   #local jj = 0;
>   #local nextx = ptArray[jj].x;
>   #local Found = false;
>   #while (!Found & (jj < dimension_size(ptArray, 1) - 1))
>     #local lastx = nextx;
>     #local jj = jj+1;
>     #local nextx = ptArray[jj].x;
>     #local Found = ((xgive >= lastx) & (xgive < nextx) ? true : false);
>   #end // while
>
>   (Found ? ptArray[jj-1].y +
>            (ptArray[jj] - ptArray[jj-1]).y*
>            sin(pi/2*(xgive - lastx)/(nextx - lastx))
>          : 0)
>
> #end // macro sinespline
>
> #declare pn =
> array[8] {
>   < 0.000,  -15.0 >,
>   < 0.250, -125.0 >,
>   < 0.350, -117.5 >,
>   < 0.450, -110.0 >,
>   < 0.500,  -10.0 >,
>   < 0.675,  -17.5 >,
>   < 0.750,  -25.0 >,
>   < 1.000,  -15.0 >
> }
>
> #declare Radius = 3;
> #declare sc = <300, 1, -3>;
>
> #declare Cnt = 0;
> #while(Cnt < 1)
>   sphere {
>     <Cnt, sinespline(Cnt, pn), 1>*sc, Radius
>     pigment{ Blue }
>     finish{ ambient 1 }
>   }
>   #declare Cnt = Cnt + .002;
> #end
>
> #declare Cnt = 0;
> #while(Cnt < dimension_size(pn, 1))
>   sphere {
>     <pn[Cnt].x, pn[Cnt].y, 1>*sc, Radius*2
>     pigment{ Red }
>     finish{ ambient 1 }
>   }
>   #declare Cnt = Cnt + 1;
> #end
>
> camera {
>   location  <130, -75, -300>
>   look_at   <130, -75,  0.0>
> }
>
> // ====================================


Post a reply to this message

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