|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I have a new macro to get a moderately smooth transition between points.
The values will not exceed the range of any interval and it does not
require one to think up two points before and after the range (8-P) as
with a cubic spline. I tried to set it up elegantly with a linear
spline and then #switch case, but I could not get the syntax correct.
Instead, one has to first manually define the points as follows:
--------------------------------------------------------
#declare pn=array[15]
#declare pn[0]=<0.00, -15>;
#declare pn[1]=<0.25, -125>;
#declare pn[2]=<0.35, -117.5>;
#declare pn[3]=<0.45, -110>;
#declare pn[4]=<0.50, -10>;
#declare pn[5]=<0.675, -17.5>;
#declare pn[6]=<0.75, -25>;
#declare pn[7]=<1.00, -15>;
#macro sinespline(n,xgive)
//where n=number of pts-1 (or # in last increment);
// x= given x for which a Y is requested for return.
#declare jj=0;
#while(jj<n)
//#debug str(jj,2,0)
#if(xgive>pn[jj].x &xgive<pn[jj+1].x)
#declare
yreturn=pn[jj].y+(pn[jj+1].y-pn[jj].y)*sin(pi/2*(xgive-pn[jj].x)/(pn[jj+1].x-pn[jj].x));
#else
#debug str(jj,2,0)
#end
#declare jj=jj+1;
#end
#end
-----------------------------------------
If anyone thinks this is of any value to humanity, please make it more
streamlined, if possible.....
Example code demonstrating differences between linear, #init_spline,
and SineSpline:
----------------------------------------------
#version unofficial MegaPov 0.4
#include "colors.inc"
#declare pn=array[15]
#init_spline {"Lshininit",
<0.00, -15>,
<0.25, -125>,
<0.45, -110>,
<0.50, -10>,
<0.75, -25>,
<1.00, -15>
}
#init_spline {"Lshininit2",
<0.00, -15>,
<0.25, -125>,
<0.35, -117.5>,
<0.45, -110>,
<0.50, -10>,
<0.675, -17.5>,
<0.75, -25>,
<1.00, -15>
}
#declare Lshinlinear=spline{
linear_spline
0.00, -15,
0.25, -125,
0.45, -110,
0.50, -10,
0.75, -25,
1.00, -15
}
#declare inputspline=spline{
linear_spline
0.00, -15,
0.25, -125,
0.45, -110,
0.50, -10,
0.75, -25,
1.00, -15
}
#declare pn[0]=<0.00, -15>;
#declare pn[1]=<0.25, -125>;
#declare pn[2]=<0.35, -117.5>;
#declare pn[3]=<0.45, -110>;
#declare pn[4]=<0.50, -10>;
#declare pn[5]=<0.675, -17.5>;
#declare pn[6]=<0.75, -25>;
#declare pn[7]=<1.00, -15>;
#macro sinespline(n,xgive)
#declare jj=0;
#while(jj<n)
//#debug str(jj,2,0)
#if(xgive>pn[jj].x &xgive<pn[jj+1].x)
#declare
yreturn=pn[jj].y+(pn[jj+1].y-pn[jj].y)*sin(pi/2*(xgive-pn[jj].x)/(pn[jj+1].x-pn[jj].x));
#else
#debug str(jj,2,0)
#end
#declare jj=jj+1;
#end
#end
#declare nn=0.001;
#while(nn<1)
sphere {<(nn+0.02)*300,Lshinlinear(nn+0.02).y,0>,3
pigment{Red}
finish{ambient 1}
}
sphere {<nn*300,eval_spline ("Lshininit",nn),3>,3
pigment{Green}
finish{ambient 1}
}
sinespline(7,nn+0.01)
//#declare yg=ygive;
sphere {<(nn+0.01)*300,yreturn,-3>,3
pigment{Blue}
finish{ambient 1}
}
#declare nn=nn+.03;
#end
camera
{
location <130, -75, -300>
look_at <130, -75, 0.0>
}
Post a reply to this message
Attachments:
Download 'sinespline.jpg' (13 KB)
Preview of image 'sinespline.jpg'
|
|
| |
| |
|
|
From: Mike Weber
Subject: Re: SineSpline: help me improve my macro! (13kbbu)
Date: 11 Apr 2000 15:03:36
Message: <38f37708@news.povray.org>
|
|
|
| |
| |
|
|
What is your goal? Is it to have a switch and case in your macro?
--
Mike
wk: mik### [at] pyxiscom www.pyxis.com
hm: mwe### [at] sciticom www.geocities.com/mikepweber
"Greg M. Johnson" <gre### [at] my-dejanewscom> wrote in message
news:38F36884.F0797519@my-dejanews.com...
> I have a new macro to get a moderately smooth transition between points.
> The values will not exceed the range of any interval and it does not
> require one to think up two points before and after the range (8-P) as
> with a cubic spline. I tried to set it up elegantly with a linear
> spline and then #switch case, but I could not get the syntax correct.
> Instead, one has to first manually define the points as follows:
> --------------------------------------------------------
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Is there a more easy way to declare everything instead of the list of
pn[0]=<a,b>, etc..........
Mike Weber wrote:
> What is your goal? Is it to have a switch and case in your macro?
>
> --
> Mike
>
> wk: mik### [at] pyxiscom www.pyxis.com
> hm: mwe### [at] sciticom www.geocities.com/mikepweber
>
> "Greg M. Johnson" <gre### [at] my-dejanewscom> wrote in message
> news:38F36884.F0797519@my-dejanews.com...
> > I have a new macro to get a moderately smooth transition between points.
> > The values will not exceed the range of any interval and it does not
> > require one to think up two points before and after the range (8-P) as
> > with a cubic spline. I tried to set it up elegantly with a linear
> > spline and then #switch case, but I could not get the syntax correct.
> > Instead, one has to first manually define the points as follows:
> > --------------------------------------------------------
Post a reply to this message
|
|
| |
| |
|
|
From: Tor Olav Kristensen
Subject: Re: SineSpline: help me improve my macro! (13kbbu)
Date: 11 Apr 2000 17:14:48
Message: <38F3948F.8C60200C@online.no>
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
From: Tor Olav Kristensen
Subject: Re: SineSpline: help me improve my macro! (13kbbu)
Date: 12 Apr 2000 12:16:51
Message: <38F4A04C.F708347D@online.no>
|
|
|
| |
| |
|
|
"Greg M. Johnson" wrote:
> PERFECT!
Thank you!
> Publish it.
It's still your macro (and idea) ... I just polished it.
So you may publish it wherever you like.
Regards
Tor Olav
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|