|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Given a loop that goes from 0 to 1, in say, 20 equal steps,
how would I use these figures to give me the same range but
in non-linear steps that "pinch" or tend to bunch together at
around 0.75?
I feel a sine function is involved but the best I have managed
is shown here which I'm not satisfied with. It shows linear Red
points converted to nonlinear Blue points.
Alf
http://www.peake42.freeserve.co.uk
http://ourworld.compuserve.com/homepages/Alf_Peake/
// Start of file
camera{ location <0.5,0,-3> angle 22 look_at x*0.5 }
light_source { -100*z rgb 1 }
plane{ -z,0 pigment{ checker 0.2, 0.5 } scale 0.1 }
cylinder{ 0, x, 0.005 pigment{ rgb <1,1,0> } } // Show range
#declare Point=1;
#while (Point>0.04)
sphere{ <Point, 0.05, 0>, 0.01 pigment{ red 1 } }
// Any suggestions here please?
#declare Try = pow( sin( Point*2 ), 2 ) - 0.17;
sphere{ <max( Point, Try ), 0, 0>, 0.01 pigment{ blue 1 } }
#declare Point=Point-0.05;
#end
file://eof
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Tue, 23 Nov 1999 23:18:44 -0000, "Alf Peake"
<alf### [at] peake42freeservecouk> wrote:
>Given a loop that goes from 0 to 1, in say, 20 equal steps,
>how would I use these figures to give me the same range but
>in non-linear steps that "pinch" or tend to bunch together at
>around 0.75?
>
>I feel a sine function is involved but the best I have managed
>is shown here which I'm not satisfied with. It shows linear Red
>points converted to nonlinear Blue points.
>
>Alf
#declare PinchPoint = 0.75;
#declare StartPoint=0;
#declare EndPoint=1;
#declare Steps=20;
#declare Points=array[Steps];
#declare Points[0]=StartPoint; #declare Points[Steps-1]=EndPoint;
#declare i=1;
#while (i<(Steps-1)/2)
#declare Points[i]=0.5*(Points[i-1]+PinchPoint);
#end
#declare i=Steps-1;
#while (i>=(Steps-1)/2)
#declare Points[i]=0.5*(Points[i+1]+PinchPoint);
#end
#declare Points[(Steps-1)/2]=PinchPoint;
//100% untested, typed it in the newsreader. Sorry, going to sleep :)
Peter Popov
pet### [at] usanet
ICQ: 15002700
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alf Peake <alf### [at] peake42freeservecouk> wrote:
> Given a loop that goes from 0 to 1, in say, 20 equal steps,
> how would I use these figures to give me the same range but
> in non-linear steps that "pinch" or tend to bunch together at
> around 0.75?
>
> I feel a sine function is involved but the best I have managed
> is shown here which I'm not satisfied with. It shows linear Red
> points converted to nonlinear Blue points.
You could use a sine curve, but this doesn't give you much control over
the amount of pinching. Perhaps breaking the linear sequence into two
sections (before and after 0.75) and applying powers to them could work
(normalising each section first, inverting the first and raising both to
the same power, and then retransforming each section back to fit):
union {
#declare C = 0; #while (C <= 1)
sphere {x*(C < .75
? (1 - pow(1 - (C/.75), 2))*.75
: pow((C-.75)/.25, 2)*.25 + .75
), .02}
#declare C = C + 1/20; #end
pigment {rgb <0, 0, 1>}}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alf Peake <alf### [at] peake42freeservecouk> wrote in message
news:383b2166@news.povray.org...
> Given a loop that goes from 0 to 1, in say, 20 equal steps,
> how would I use these figures to give me the same range but
> in non-linear steps that "pinch" or tend to bunch together at
> around 0.75?
>
I use a simple sine function to offset the peak a little, perhaps it will
help you.
////////////// Camera //////////////////////
camera { //
right < -1.333, 0.0, 0.0 > //
up < 0.0, 1.0, 0.0 > //
direction < 0.0, 0.0, 1.0 > //
location < 0.0, 0.0, 4.0 > //
look_at < 0.0, 0.0, 0.0 > //
} //
////////////// end Camera //////////////////
/////////////// Light ////////////////
light_source { < 100.0, 100.0, 100.0 >
color rgb < 1.0, 1.0, 1.0 > }
///////////////////////////////////////
#declare I = 0;
#while ( I < 1)
sphere {0, 0.05 pigment { rgb 1 } translate < I, sin((I*I*I)*pi), 0 > }
#declare I = I + 0.001;
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I've uploaded to my freeserve site an 800*600 52k jpeg to show why I was
yelling for help. I wanted a spider's web to go with my 2 year old spider on
Compuserve homepage. One part completed fly to go. Been nibbling at the web
problem for months.
Your solution looks just dandy Chris, many thanks and looks like I can sleep
now :o)
Thanks Bill for your suggestion. Curve is the right shape but x-spacing is
linear. I can work from that tho' if I need to..
And Peter - still working on yours before I had to get upstairs too. Added
the loop decrements as well <i=i-1> incase anyone is puzzled.
Alf
One spider's web (under construction ;-)
http://www.peake42.freeserve.co.uk/pix1/web.jpg
and 1 completed hairy spider:
http://ourworld.compuserve.com/homepages/Alf_Peake/
Chris Colefax <cco### [at] geocitiescom> wrote in message
news:383bde32@news.povray.org...
> Alf Peake <alf### [at] peake42freeservecouk> wrote:
> > Given a loop that goes from 0 to 1, in say, 20 equal steps,
> > how would I use these figures to give me the same range but
> > in non-linear steps that "pinch" or tend to bunch together at
> > around 0.75?
> >
> > I feel a sine function is involved but the best I have managed
> > is shown here which I'm not satisfied with. It shows linear Red
> > points converted to nonlinear Blue points.
>
> You could use a sine curve, but this doesn't give you much control over
> the amount of pinching. Perhaps breaking the linear sequence into two
> sections (before and after 0.75) and applying powers to them could work
> (normalising each section first, inverting the first and raising both to
> the same power, and then retransforming each section back to fit):
>
> union {
> #declare C = 0; #while (C <= 1)
> sphere {x*(C < .75
> ? (1 - pow(1 - (C/.75), 2))*.75
> : pow((C-.75)/.25, 2)*.25 + .75
> ), .02}
> #declare C = C + 1/20; #end
> pigment {rgb <0, 0, 1>}}
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Thu, 25 Nov 1999 14:33:02 -0000, "Alf Peake"
<alf### [at] peake42freeservecouk> wrote:
>And Peter - still working on yours before I had to get upstairs too. Added
>the loop decrements as well <i=i-1> incase anyone is puzzled.
>
>Alf
You mean you have to decrement those loop control variables? Adding
them does seem to make parsing a helluva lot easier indeed :)
Peter Popov
pet### [at] usanet
ICQ: 15002700
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alf Peake <alf### [at] peake42freeservecouk> wrote :
>
> Thanks Bill for your suggestion.
>
You're welcome, but you made me curious and now I am working on making
an easy way to peak at whatever place you want to while making the whole
curve smooth. I haven't studied Chris's and Peter's yet because I want to
see what I can come up with by myself...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Thu, 25 Nov 1999 15:57:20 -0500, "Bill DeWitt"
<the### [at] earthlinknet> wrote:
> You're welcome, but you made me curious and now I am working on making
>an easy way to peak at whatever place you want to while making the whole
>curve smooth. I haven't studied Chris's and Peter's yet because I want to
>see what I can come up with by myself...
Beware of infinitely long parsing times with mine :)
Peter Popov
pet### [at] usanet
ICQ: 15002700
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Bill DeWitt <the### [at] earthlinknet> wrote:
> You're welcome, but you made me curious and now I am working on
making
> an easy way to peak at whatever place you want to while making the
whole
> curve smooth. I haven't studied Chris's and Peter's yet because I want
to
> see what I can come up with by myself...
I think this may be somewhat difficult with a spline curve: to pinch a
linear sequence (in one dimension) you need an ever-increasing curve
that slows down as it approaches the pinch point and speeds up
afterwards. A spline curve, though, is only increasing from -pi/2 to
pi/2 (plus or minus whole multiples of 2*pi), and in this period the
curve accelerates from the start and decelerates towards the end. This
pinches the spacing towards the beginning and end, and stretches it in
the middle - the opposite of what we're looking for!
Parametising the code I posted shouldn't be too hard, eg:
#declare PinchPoint = 0.75;
#declare PinchPower = 2; // 1 = no pinching, increase for more
union {
#declare C = 0; #while (C <= 1)
sphere {x*(C < PinchPoint
? (1 - pow(1 - (C/PinchPoint), PinchPower))*PinchPoint
: pow((C-PinchPoint)/(1-PinchPoint), PinchPower)*(1-PinchPoint)
+ PinchPoint
), .02}
#declare C = C + 1/20; #end
pigment {rgb <0, 0, 1>}}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Chris Colefax <cco### [at] geocitiescom> wrote :
>
> Parametising the code I posted shouldn't be too hard, eg:
>
Well, I came up with almost (but not quite I don't think) exactly what Chris
came up with.
Not that that is bad, I just wish I had come up with something new and
unusual... to see it, run this in an animation with about 20 frames or more.
Or see Graph.avi in p.b.a.
/// Begin pov code
////////////// Camera ////////////////////////
camera
right < -4/3, 0.0, 0.0 >
up < 0.0, 1.0, 0.0 >
direction < 0.0, 0.0, 1.0 >
location < 0.0, 0.0, 3.0 >
look_at < 0.0, 0.0, 0.0 >
}
/////////////// Light //////////////////
light_source { < 100.0, 200.0, 200.0 >
color rgb < 1.0, 1.0, 1.0 > }
////////////////////////////////////////////////////////////////////////////
//////////
/// #include "C:\My Documents\PovFiles\tools\TestPad.inc"
TestPad( <-1.0, -1.0, 0.0 >)
#macro Peak( Location, Height, Index, Power )
/// While Index is less than Location, rises from 0 to 1
/// While Index is greater than Location descends to 0
/// Location is where you want the peak to be,
/// Height is how far up the pinch goes,
/// Index is whatever you use to increment the value,
/// Power is the slope, 1 is linear, 2 is curved and higher is
sharper
// fix divide by zero
#if ( Location = 0.0 )
#local Location = 0.0001;
#end
/// This is the calculation of the value
(
( Index <= Location ) ?
pow( ( Index / Location ), Power )*Height :
pow( (1-Index)/(1-Location ), Power )*Height
)
#end
/// A bunch of arbitrary values
#declare Location = clock;
#declare Height = (sin(clock*pi)/2)+0.25;
#declare Power = 3.0;
/// Loop to draw a line
#declare Index = 0.0;
#while (Index < 1 )
sphere {0, 0.04 pigment { rgb < Peak ( Location, Height, Index,
Power ),
0.0,
1.0-Peak ( Location, Height, Index,
Power ) >
}
finish { ambient 1 }
translate < Index, Peak ( Location, Height, Index,
Power ), 0 > }
#declare Index = Index + 0.005;
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|