POV-Ray : Newsgroups : povray.newusers : POC crashes using spline Server Time
4 Jul 2024 14:00:05 EDT (-0400)
  POC crashes using spline (Message 1 to 4 of 4)  
From: geogeo
Subject: POC crashes using spline
Date: 10 Jan 2010 15:05:01
Message: <web.4b4a31f4b364303c7a10edb40@news.povray.org>
I've been battling with this for some hours now so thought it time to cry Help!
Trying to place objects along a helix using a spline, code as below. When I
activate the the commented out bit (last section of code) POV crashes every
time. Any ideas anyone?
Thanks, Geo

// generate helix -----------------------------------------
#declare R1=3.5;     //outer radius
#declare F1=0.2;     //point spacing
#declare N=100;      //points on helix   200
#declare H=20;       //tightness

//set up helical spline -------------------------------------------
#declare P2 = array[N][3];
#declare j=0;
#while (j<N)
 #declare P2[j][0] = (j*H/N)-(H/2);
 #declare P2[j][1] = R1*sin(F1*j);
 #declare P2[j][2] = R1*cos(F1*j);
 #declare j=j+1;
#end

#declare j=0;
#while (j<N)
  #declare helix_spline1 =
  spline { natural_spline
  j/N, <P2[j][0],P2[j][1],P2[j][2]>
  #debug concat("helix = ", str(j/N,0,-1)," ", str(P2[j][0],0,-1)," ",
str(P2[j][1],0,-1)," ",  str(P2[j][2],0,-1), "\n")
  #declare j=j+1;
         }
#end

//place objects along helix ---------------------------------------
#declare helix_object =
 sphere { <0,0,0>, 0.2
          texture {pigment { Green }  finish { ambient 0.1 diffuse 0.5  phong
..4}
                  }
        }

/*
 #declare cnt=0;
 #while (cnt<1)
  object { helix_object
          translate helix_spline1(cnt   )
         }
  #declare cnt = cnt + 0.1;
 #end
*/


Post a reply to this message

From: geogeo
Subject: Re: POC crashes using spline
Date: 10 Jan 2010 17:50:00
Message: <web.4b4a596d21d3af227a10edb40@news.povray.org>
"geogeo" <geo### [at] mecolcouk> wrote:
> I've been battling with this for some hours now so thought it time to cry Help!
> Trying to place objects along a helix using a spline, code as below. When I
> activate the the commented out bit (last section of code) POV crashes every
> time. Any ideas anyone?
> Thanks, Geo
>
> // generate helix -----------------------------------------
> #declare R1=3.5;     //outer radius
> #declare F1=0.2;     //point spacing
> #declare N=100;      //points on helix   200
> #declare H=20;       //tightness
>
> //set up helical spline -------------------------------------------
> #declare P2 = array[N][3];
> #declare j=0;
> #while (j<N)
>  #declare P2[j][0] = (j*H/N)-(H/2);
>  #declare P2[j][1] = R1*sin(F1*j);
>  #declare P2[j][2] = R1*cos(F1*j);
>  #declare j=j+1;
> #end
>
> #declare j=0;
> #while (j<N)
>   #declare helix_spline1 =
>   spline { natural_spline
>   j/N, <P2[j][0],P2[j][1],P2[j][2]>
>   #debug concat("helix = ", str(j/N,0,-1)," ", str(P2[j][0],0,-1)," ",
> str(P2[j][1],0,-1)," ",  str(P2[j][2],0,-1), "\n")
>   #declare j=j+1;
>          }
> #end
>
> //place objects along helix ---------------------------------------
> #declare helix_object =
>  sphere { <0,0,0>, 0.2
>           texture {pigment { Green }  finish { ambient 0.1 diffuse 0.5  phong
> ..4}
>                   }
>         }
>
> /*
>  #declare cnt=0;
>  #while (cnt<1)
>   object { helix_object
>           translate helix_spline1(cnt   )
>          }
>   #declare cnt = cnt + 0.1;
>  #end
> */

Have now resolved this, seems the term natural_sline which I got from a tutorial
is the problem, changed it to quardratic_spline then no more crashes.
However the while loop surrounding the spline is flawed and doesn't define the
spline at all but a load of single point splines! Can't yet see a way to do this
without tediously defining each point - any ideas anyone?
Geo


Post a reply to this message

From: Reactor
Subject: Re: POC crashes using spline
Date: 11 Jan 2010 00:05:01
Message: <web.4b4ab09421d3af2292f1d6f50@news.povray.org>
"geogeo" <geo### [at] mecolcouk> wrote:
> "geogeo" <geo### [at] mecolcouk> wrote:
> > I've been battling with this for some hours now so thought it time to cry Help!
> > Trying to place objects along a helix using a spline, code as below. When I
> > activate the the commented out bit (last section of code) POV crashes every
> > time. Any ideas anyone?
> > Thanks, Geo
> >
> > // generate helix -----------------------------------------
> > #declare R1=3.5;     //outer radius
> > #declare F1=0.2;     //point spacing
> > #declare N=100;      //points on helix   200
> > #declare H=20;       //tightness
> >
> > //set up helical spline -------------------------------------------
> > #declare P2 = array[N][3];
> > #declare j=0;
> > #while (j<N)
> >  #declare P2[j][0] = (j*H/N)-(H/2);
> >  #declare P2[j][1] = R1*sin(F1*j);
> >  #declare P2[j][2] = R1*cos(F1*j);
> >  #declare j=j+1;
> > #end
> >
> > #declare j=0;
> > #while (j<N)
> >   #declare helix_spline1 =
> >   spline { natural_spline
> >   j/N, <P2[j][0],P2[j][1],P2[j][2]>
> >   #debug concat("helix = ", str(j/N,0,-1)," ", str(P2[j][0],0,-1)," ",
> > str(P2[j][1],0,-1)," ",  str(P2[j][2],0,-1), "\n")
> >   #declare j=j+1;
> >          }
> > #end
> >
> > //place objects along helix ---------------------------------------
> > #declare helix_object =
> >  sphere { <0,0,0>, 0.2
> >           texture {pigment { Green }  finish { ambient 0.1 diffuse 0.5  phong
> > ..4}
> >                   }
> >         }
> >
> > /*
> >  #declare cnt=0;
> >  #while (cnt<1)
> >   object { helix_object
> >           translate helix_spline1(cnt   )
> >          }
> >   #declare cnt = cnt + 0.1;
> >  #end
> > */
>
> Have now resolved this, seems the term natural_sline which I got from a tutorial
> is the problem, changed it to quardratic_spline then no more crashes.
> However the while loop surrounding the spline is flawed and doesn't define the
> spline at all but a load of single point splines! Can't yet see a way to do this
> without tediously defining each point - any ideas anyone?
> Geo



Your loop body has some parts that are supposed to be loop invariant.  The
declaration and closing brace should be outside of the loop.  Note that this may
require trickery to get your commas right.
Consider:

#declare j=0;
  #declare helix_spline1 =
  spline { natural_spline
#while (j<N)
  j/N, <P2[j][0],P2[j][1],P2[j][2]>
  #debug concat("helix = ", str(j/N,0,-1)," ", str(P2[j][0],0,-1)," ",
str(P2[j][1],0,-1)," ",  str(P2[j][2],0,-1), "\n")
  #declare j=j+1;
#end
   } // closing brace outside


Your old code was just redefining helix_spline1 as a single point spline
repeatedly instead of building the whole spline from the array.

-Reactor


Post a reply to this message

From: geogeo
Subject: Re: POC crashes using spline
Date: 11 Jan 2010 10:25:00
Message: <web.4b4b41c721d3af227a10edb40@news.povray.org>
"Reactor" <rea### [at] hotmailcom> wrote:
> "geogeo" <geo### [at] mecolcouk> wrote:
> > "geogeo" <geo### [at] mecolcouk> wrote:
> > > I've been battling with this for some hours now so thought it time to cry Help!
> > > Trying to place objects along a helix using a spline, code as below. When I
> > > activate the the commented out bit (last section of code) POV crashes every
> > > time. Any ideas anyone?
> > > Thanks, Geo
> > >
> > > // generate helix -----------------------------------------
> > > #declare R1=3.5;     //outer radius
> > > #declare F1=0.2;     //point spacing
> > > #declare N=100;      //points on helix   200
> > > #declare H=20;       //tightness
> > >
> > > //set up helical spline -------------------------------------------
> > > #declare P2 = array[N][3];
> > > #declare j=0;
> > > #while (j<N)
> > >  #declare P2[j][0] = (j*H/N)-(H/2);
> > >  #declare P2[j][1] = R1*sin(F1*j);
> > >  #declare P2[j][2] = R1*cos(F1*j);
> > >  #declare j=j+1;
> > > #end
> > >
> > > #declare j=0;
> > > #while (j<N)
> > >   #declare helix_spline1 =
> > >   spline { natural_spline
> > >   j/N, <P2[j][0],P2[j][1],P2[j][2]>
> > >   #debug concat("helix = ", str(j/N,0,-1)," ", str(P2[j][0],0,-1)," ",
> > > str(P2[j][1],0,-1)," ",  str(P2[j][2],0,-1), "\n")
> > >   #declare j=j+1;
> > >          }
> > > #end
> > >
> > > //place objects along helix ---------------------------------------
> > > #declare helix_object =
> > >  sphere { <0,0,0>, 0.2
> > >           texture {pigment { Green }  finish { ambient 0.1 diffuse 0.5  phong
> > > ..4}
> > >                   }
> > >         }
> > >
> > > /*
> > >  #declare cnt=0;
> > >  #while (cnt<1)
> > >   object { helix_object
> > >           translate helix_spline1(cnt   )
> > >          }
> > >   #declare cnt = cnt + 0.1;
> > >  #end
> > > */
> >
> > Have now resolved this, seems the term natural_sline which I got from a tutorial
> > is the problem, changed it to quardratic_spline then no more crashes.
> > However the while loop surrounding the spline is flawed and doesn't define the
> > spline at all but a load of single point splines! Can't yet see a way to do this
> > without tediously defining each point - any ideas anyone?
> > Geo
>
>
>
> Your loop body has some parts that are supposed to be loop invariant.  The
> declaration and closing brace should be outside of the loop.  Note that this may
> require trickery to get your commas right.
> Consider:
>
> #declare j=0;
>   #declare helix_spline1 =
>   spline { natural_spline
> #while (j<N)
>   j/N, <P2[j][0],P2[j][1],P2[j][2]>
>   #debug concat("helix = ", str(j/N,0,-1)," ", str(P2[j][0],0,-1)," ",
> str(P2[j][1],0,-1)," ",  str(P2[j][2],0,-1), "\n")
>   #declare j=j+1;
> #end
>    } // closing brace outside
>
>
> Your old code was just redefining helix_spline1 as a single point spline
> repeatedly instead of building the whole spline from the array.
>
> -Reactor

Yes, I realised the single point spline problem soon after I'd stopped it all
crashing, but couldn't get the loop structure right - so thanks, yours works
just fine. I'd patched around it by using debug to write all the spline points,
saving them as an inc then including the inc as part of the spline declaration.
Not very elegant but it worked!

Must say I'm really bowled over by this software. Been at it for a week now and
have two animations done as part of a video project I have in mind. POV is pure
magic.

And so nice to have backup when I get stuck,
thanks
Geo


Post a reply to this message

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