POV-Ray : Newsgroups : povray.newusers : splines of variable length Server Time
26 Nov 2024 17:19:57 EST (-0500)
  splines of variable length (Message 1 to 8 of 8)  
From: bongotastic
Subject: splines of variable length
Date: 21 Feb 2004 14:16:34
Message: <4037ae92$1@news.povray.org>
Hi,

    I would like to display sphere_sweep(s) of a variable length. Here is
approximatively what I want to do:

#while(some_condition)
#declare n = Rand_Poisson(10,myseed);
// generate an array of n points according to some process
{...}
// Draw a sphere_sweep such that
sphere_sweep{
    cubic_spline
    n,
    // My n points here
    ...
    texture{...}
}
#end // end while loop

    I can't find any example doing something similar. Is it possible or must
all spline length must be hard coded?

    Thanks in advance


Post a reply to this message

From: Hughes, B 
Subject: Re: splines of variable length
Date: 21 Feb 2004 17:12:03
Message: <4037d7b3@news.povray.org>
"bongotastic" <cbl### [at] csdalca> wrote in message
news:4037ae92$1@news.povray.org...
>
>     I would like to display sphere_sweep(s) of a variable length. Here is
> approximatively what I want to do:
>
> #while(some_condition)
> #declare n = Rand_Poisson(10,myseed);
> // generate an array of n points according to some process
> {...}
> // Draw a sphere_sweep such that
> sphere_sweep{
>     cubic_spline
>     n,
>     // My n points here
>     ...
>     texture{...}
> }
> #end // end while loop
>
>     I can't find any example doing something similar. Is it possible or
must
> all spline length must be hard coded?

sphere_sweep doesn't seem to accept all the points given it by #while loop,
from what I've found. Take the following script as an example:

#declare SpaceTime=
spline {
 linear_spline
  0.0, <-50, 0, 0>,
  0.1, <-50, 0, -20>,
  0.2, <-20, 0, -20>,
  0.3, <-20, 0, 0>,
  0.4, <0, 0, 0>,
  0.5, <30, 0, 0>,
  0.6, <30, 0, 10>,
  0.7, <40, 0, 10>,
  0.8, <40, 0, 20>,
  0.9, <80, 0, 20>,
  1.0, <80, 0, 20>
}

#macro SphereSweep(P,F)
#local Frame=frame_number+F;
 linear_spline
 Frame,
 SpaceTime(0),1
 #while (P<Frame)
 SpaceTime(clock),1
 #local P=P+1;
 #end
#end

sphere_sweep {
 SphereSweep(1,2)

pigment {color rgb 1}
}

What happens is that only the first and then last point, produced in the
loop, is actually plotted leaving the others out. Makes a single line
without any corners, such as were planned in the SpaceTime() spline.

Sorry that I'm of no help. Of course, this doesn't mean there's not another
way until disproven.

-- 
Bob H.
http://www.3digitaleyes.com


Post a reply to this message

From: Carl Hoff
Subject: Re: splines of variable length
Date: 22 Feb 2004 00:50:05
Message: <4038430d@news.povray.org>
I believe I'm facing the same problem.  You may want to look at the code I
just posted over in povray.binaries.scene-files in the thread with the
subject "A solution to my light cycle/spline problem".

If you find a solution PLEASE share.

Thanks,
Carl


Post a reply to this message

From: Mike Williams
Subject: Re: splines of variable length
Date: 22 Feb 2004 01:04:41
Message: <0qylGBAyYEOAFwPa@econym.demon.co.uk>
Wasn't it Hughes, B. who wrote:
>sphere_sweep doesn't seem to accept all the points given it by #while loop,
>from what I've found. Take the following script as an example:
>
>#declare SpaceTime=
>spline {
> linear_spline
>  0.0, <-50, 0, 0>,
>  0.1, <-50, 0, -20>,
>  0.2, <-20, 0, -20>,
>  0.3, <-20, 0, 0>,
>  0.4, <0, 0, 0>,
>  0.5, <30, 0, 0>,
>  0.6, <30, 0, 10>,
>  0.7, <40, 0, 10>,
>  0.8, <40, 0, 20>,
>  0.9, <80, 0, 20>,
>  1.0, <80, 0, 20>
>}
>
>#macro SphereSweep(P,F)
>#local Frame=frame_number+F;
> linear_spline
> Frame,
> SpaceTime(0),1
> #while (P<Frame)
> SpaceTime(clock),1
> #local P=P+1;
> #end
>#end
>
>sphere_sweep {
> SphereSweep(1,2)
>
>pigment {color rgb 1}
>}
>
>What happens is that only the first and then last point, produced in the
>loop, is actually plotted leaving the others out. Makes a single line
>without any corners, such as were planned in the SpaceTime() spline.

What happens there is that "clock" takes one value in any one frame. So,
for any one frame, SpaceTime(clock) is always the same point.

I think you want something more like this:
  
// MySphereSweep
//   Start and End take values in range 0.0 - 1.0
#macro MySphereSweep(Start,End,TotalPoints)
#local Points=int((End-Start)*TotalPoints);
#if (Points>1)
  #local N=0;
   linear_spline
   Points,
   #while (N<Points)
     #local P= Start+N/TotalPoints;
     SpaceTime(P),1
     #local N=N+1;
   #end
 #else
   linear_spline 2,0,0,0,0
 #end
#end


sphere_sweep {
 MySphereSweep(0.0,clock,20)
 pigment {color rgb 1}
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Kurts
Subject: Re: splines of variable length
Date: 22 Feb 2004 04:38:32
Message: <kurtzlepirate-698849.10382722022004@news.povray.org>
In article <4037d7b3@news.povray.org>, "Hughes, B." <omn### [at] charternet> 
wrote:

> sphere_sweep doesn't seem to accept all the points given it by #while loop,
> from what I've found.

  ??? and why not ?

#declare sphereRadius = ...;
#declare myPoint = <0, 0, 0>;
#declare index = 0;

#declare mySphereSweep = sphere_sweep {
  cubic_spline
  n,
  #while (index<n)
    #set myPoint = compute x,y,z for index's point;
    <myPoint.x, myPoint.y, myPoint.z>, sphereRadius
    #set index=index+1;
  #end
  }

then use :
  object { mySphereSweep texture { } }

a+


Post a reply to this message

From: Carl Hoff
Subject: Re: splines of variable length
Date: 22 Feb 2004 08:54:49
Message: <4038b4a9@news.povray.org>
Thanks guys...

   I replaced my spline declaration with this and all works fine.

#declare path1_spline = spline {
  linear_spline
  #declare ctr = 0;
  #while (ctr < path1_num - 0.5)
    path1_seg_time[ctr], path1[ctr][0],
    #declare ctr = ctr + 1;
  #end
}


"Kurts" <kur### [at] yahoofr> wrote in message
news:kurtzlepirate-698849.10382722022004@news.povray.org...
> In article <4037d7b3@news.povray.org>, "Hughes, B."
<omn### [at] charternet>
> wrote:
>
> > sphere_sweep doesn't seem to accept all the points given it by #while
loop,
> > from what I've found.
>
>   ??? and why not ?
>
> #declare sphereRadius = ...;
> #declare myPoint = <0, 0, 0>;
> #declare index = 0;
>
> #declare mySphereSweep = sphere_sweep {
>   cubic_spline
>   n,
>   #while (index<n)
>     #set myPoint = compute x,y,z for index's point;
>     <myPoint.x, myPoint.y, myPoint.z>, sphereRadius
>     #set index=index+1;
>   #end
>   }
>
> then use :
>   object { mySphereSweep texture { } }
>
> a+


Post a reply to this message

From: Hughes, B 
Subject: Re: splines of variable length
Date: 22 Feb 2004 09:48:08
Message: <4038c128$1@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:0qy### [at] econymdemoncouk...
> Wasn't it Hughes, B. who wrote:
> >sphere_sweep doesn't seem to accept all the points given it by #while
loop,
>
> What happens there is that "clock" takes one value in any one frame. So,
> for any one frame, SpaceTime(clock) is always the same point.


I'll have to slap my forehead about this. It just had to be that simple,
huh? I kept seeing it (clock) as being a range everytime I looked it over
trying to figure out why that while loop couldn't produce a list of points.
Totally dumb of me. Well, that happens a lot when no one is around to help
me. Carl is probably real happy now. Thanks a bunch Mike.

-- 
Bob H.
http://www.3digitaleyes.com


Post a reply to this message

From: Hughes, B 
Subject: Re: splines of variable length
Date: 22 Feb 2004 09:57:14
Message: <4038c34a$1@news.povray.org>
Thanks from me too, Kurt.

I see how my error was in using a bad variable (which was 'clock') that only
changed each frame of animation. It couldn't change within a while loop!

Bob H.


Post a reply to this message

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