POV-Ray : Newsgroups : povray.general : Spline vector function Server Time: 22 Oct 2017 21:02:51 GMT
  Spline vector function (Message 1 to 10 of 10)  
From: John Greenwood
Subject: Spline vector function
Date: 19 Nov 2016 18:40:00
Message: <web.58309bfd590a407fa7cafab50@news.povray.org>
I am experimenting with this:
#version 3.7 ;
  global_settings {assumed_gamma 1.0 }

    camera {location <-10,40,-40> angle 4 look_at <0,0,0> }
    light_source {<-5,20,-20> colour rgb<1,1,1>}
  background { color rgb<0.2, 0.4, 0.8>  }


#declare Place = function {
  spline {
    linear_spline
//    -4, <-10,0,-2>
    -2, <0,0,-1>
    0, <1,0,0>
    2.0, <0,1,1>
    }
  }
 sphere {Place(-1),.1 pigment {color rgb < 1, 0, 0>}}
 sphere {Place(-.5),.1pigment {color rgb < 1, 1, 0>} }
 sphere {Place(-0),.1 pigment {color rgb < 0, 1, 0>}}
 sphere {Place(+.5),.1 pigment {color rgb < 1, 0, 1>}}
 sphere {Place(+1),.1 pigment {color rgb < 0, 0, 1>}}

This seems to work but if I add another point by deleting the // I get an error
which does not make sense (to me).

Should it be possible to do arbitarily long bezier splines?


Post a reply to this message

From: William F Pokorny
Subject: Re: Spline vector function
Date: 19 Nov 2016 19:36:53
Message: <5830a9d5$1@news.povray.org>
On 11/19/2016 01:37 PM, John Greenwood wrote:
> I am experimenting with this:
> #version 3.7 ;
>   global_settings {assumed_gamma 1.0 }
>
>     camera {location <-10,40,-40> angle 4 look_at <0,0,0> }
>     light_source {<-5,20,-20> colour rgb<1,1,1>}
>   background { color rgb<0.2, 0.4, 0.8>  }
>
>
> #declare Place = function {
>   spline {
>     linear_spline
> //    -4, <-10,0,-2>
>     -2, <0,0,-1>
>     0, <1,0,0>
>     2.0, <0,1,1>
>     }
>   }
>  sphere {Place(-1),.1 pigment {color rgb < 1, 0, 0>}}
>  sphere {Place(-.5),.1pigment {color rgb < 1, 1, 0>} }
>  sphere {Place(-0),.1 pigment {color rgb < 0, 1, 0>}}
>  sphere {Place(+.5),.1 pigment {color rgb < 1, 0, 1>}}
>  sphere {Place(+1),.1 pigment {color rgb < 0, 0, 1>}}
>
> This seems to work but if I add another point by deleting the // I get an error
> which does not make sense (to me).
>
> Should it be possible to do arbitarily long bezier splines?
>
>
Hi John,
Yes, you should be able to have arbitrarily long splines. I've certainly 
had much longer.

To me this looks like a parse bug going back to at least 3.6.1 where a 
negative index value in other than the first entry fails.

A scene file with just this works:

#declare MySpline =
  spline {
  linear_spline
  -4, <-10,0,-2>
  0, <0,0,-1>
  1, <1,0,0>
  2.0, <0,1,1>
}

but this doesn't:

#declare MySpline =
  spline {
  linear_spline
  -4, <-10,0,-2>
  -0, <0,0,-1>
  1, <1,0,0>
  2.0, <0,1,1>
}

That said, I'll let this sit a bit in case those around longer know 
something I do not and want to chime in.

Otherwise, I'll open up an issue for it in a day or two.

Bill P.


Post a reply to this message

From: clipka
Subject: Re: Spline vector function
Date: 19 Nov 2016 19:55:34
Message: <5830ae36$1@news.povray.org>
Am 19.11.2016 um 19:37 schrieb John Greenwood:

> #declare Place = function {
>   spline {
>     linear_spline
> //    -4, <-10,0,-2>
>     -2, <0,0,-1>
>     0, <1,0,0>
>     2.0, <0,1,1>
>     }
>   }
[...]
> This seems to work but if I add another point by deleting the // I get an error
> which does not make sense (to me).

It's not a bug, it's a feature.

Re-formatting gives the following code:

  #declare Place = function {
    spline {
    linear_spline
      -4, <-10,0,-2>-2,
      <0,0,-1> 0,
      <1,0,0> 2.0,
      <0,1,1>
    }
  }

Since `<-10,0,-2>-2` is a valid vector expression, that's how POV-Ray
will interpret it.

Using more commas should fix the ambiguity of the code and thus solve
the problem.


Post a reply to this message

From: omniverse
Subject: Re: Spline vector function
Date: 19 Nov 2016 20:00:01
Message: <web.5830aefdf8564a279c5d6c810@news.povray.org>
Using a comma after each vector also works okay.


Post a reply to this message

From: John Greenwood
Subject: Re: Spline vector function
Date: 20 Nov 2016 10:00:00
Message: <web.5831737ff8564a27a7cafab50@news.povray.org>
"omniverse" <omn### [at] charternet> wrote:
> Using a comma after each vector also works okay.

Works for me too.

Thanks everyone for the help.


Post a reply to this message

From: William F Pokorny
Subject: Re: Spline vector function
Date: 20 Nov 2016 12:46:26
Message: <58319b22$1@news.povray.org>
On 11/19/2016 02:55 PM, clipka wrote:
> Am 19.11.2016 um 19:37 schrieb John Greenwood:
>
>
> It's not a bug, it's a feature.
>
> Re-formatting gives the following code:
>
>   #declare Place = function {
>     spline {
>     linear_spline
>       -4, <-10,0,-2>-2,
>       <0,0,-1> 0,
>       <1,0,0> 2.0,
>       <0,1,1>
>     }
>   }
>
> Since `<-10,0,-2>-2` is a valid vector expression, that's how POV-Ray
> will interpret it.
>
> Using more commas should fix the ambiguity of the code and thus solve
> the problem.
>
Ah, yes... Thanks.

Bill P.


Post a reply to this message

From: omniverse
Subject: Re: Spline vector function
Date: 20 Nov 2016 15:35:01
Message: <web.5831c28cf8564a279c5d6c810@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
> On 11/19/2016 02:55 PM, clipka wrote:
> > Since `<-10,0,-2>-2` is a valid vector expression, that's how POV-Ray
> > will interpret it.
> >
> > Using more commas should fix the ambiguity of the code and thus solve
> > the problem.

I see I replied less than 5 minutes after this was said, posting delay got me.

I just wanted to point something out. A comma after *every* vector is apparently
possible, I just hadn't actually said that before. I was surprised it didn't
cause a parse error.

Looking at the documentation, spline examples leave out the trailing commas but
the spline definition denotes them as optional (without final comma).

So to be sure other things don't allow a final comma, which is what I had
expected, I tried doing that with sor, lathe and sphere_sweep. Sure enough,
parse error. No doubt countless times I've dealt with this comma error thing in
the past.

I wonder if spline is the only thing allowing that last ,
And wondering if it makes more sense to allow that for everything listing
vectors or exclude the possibility. Of course I would have to lean toward
allowing it, thinking if sections of vector lists were generated externally and
added or subtracted somehow, else the error would occur.


Post a reply to this message

From: clipka
Subject: Re: Spline vector function
Date: 20 Nov 2016 15:56:35
Message: <5831c7b3$1@news.povray.org>
Am 20.11.2016 um 16:34 schrieb omniverse:

> Looking at the documentation, spline examples leave out the trailing commas but
> the spline definition denotes them as optional (without final comma).
> 
> So to be sure other things don't allow a final comma, which is what I had
> expected, I tried doing that with sor, lathe and sphere_sweep. Sure enough,
> parse error. No doubt countless times I've dealt with this comma error thing in
> the past.
> 
> I wonder if spline is the only thing allowing that last ,
> And wondering if it makes more sense to allow that for everything listing
> vectors or exclude the possibility. Of course I would have to lean toward
> allowing it, thinking if sections of vector lists were generated externally and
> added or subtracted somehow, else the error would occur.

I'm a bit surprised about your findings, as it was my impression that
POV-Ray generally allowed a final comma.

Can you report your findings as an issue on
https://github.com/POV-Ray/povray/issues so we don't lose track of this?
Thanks.


Post a reply to this message

From: omniverse
Subject: Re: Spline vector function
Date: 20 Nov 2016 17:05:02
Message: <web.5831d773f8564a279c5d6c810@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 20.11.2016 um 16:34 schrieb omniverse:
>
> > Looking at the documentation, spline examples leave out the trailing commas but
> > the spline definition denotes them as optional (without final comma).
> >
> > So to be sure other things don't allow a final comma, which is what I had
> > expected, I tried doing that with sor, lathe and sphere_sweep. Sure enough,
> > parse error.>
> I'm a bit surprised about your findings, as it was my impression that
> POV-Ray generally allowed a final comma.
>
> Can you report your findings as an issue on
> https://github.com/POV-Ray/povray/issues so we don't lose track of this?

Done, whatever way I'm going about it there is probably another matter.  :)

https://github.com/POV-Ray/povray/issues/153

And now found prism and polygon complain with that final comma added.

Not so with polynomial. I'm not sure what else might be considered similar
enough to these objects or functions.


Post a reply to this message

From: Alain
Subject: Re: Spline vector function
Date: 20 Nov 2016 22:30:07
Message: <583223ef@news.povray.org>
Le 16-11-19 à 13:37, John Greenwood a écrit :
> I am experimenting with this:
> #version 3.7 ;
>   global_settings {assumed_gamma 1.0 }
>
>     camera {location <-10,40,-40> angle 4 look_at <0,0,0> }
>     light_source {<-5,20,-20> colour rgb<1,1,1>}
>   background { color rgb<0.2, 0.4, 0.8>  }
>
>
> #declare Place = function {
>   spline {
>     linear_spline
> //    -4, <-10,0,-2>
>     -2, <0,0,-1>
>     0, <1,0,0>
>     2.0, <0,1,1>
>     }
>   }
>  sphere {Place(-1),.1 pigment {color rgb < 1, 0, 0>}}
>  sphere {Place(-.5),.1pigment {color rgb < 1, 1, 0>} }
>  sphere {Place(-0),.1 pigment {color rgb < 0, 1, 0>}}
>  sphere {Place(+.5),.1 pigment {color rgb < 1, 0, 1>}}
>  sphere {Place(+1),.1 pigment {color rgb < 0, 0, 1>}}
>
> This seems to work but if I add another point by deleting the // I get an error
> which does not make sense (to me).
>
> Should it be possible to do arbitarily long bezier splines?
>
>

You should add some comas in your points list. Your second component is 
starting with -2. This cause the whole statement to be interpreted as:
-4, <-10,0,-2>-2, <0,0,-1>,...
whitch becomes:
-4, <-12, -2, -4>, <0,0,1>,...

Remember, spaces, tabs and new lines/cariage returns et NOT terminal 
separators.

Alain


Post a reply to this message

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