POV-Ray : Newsgroups : povray.beta-test : splines - documentation and reality Server Time
2 Nov 2024 03:15:40 EDT (-0400)
  splines - documentation and reality (Message 1 to 4 of 4)  
From:
Subject: splines - documentation and reality
Date: 10 Jan 2002 03:12:42
Message: <m7fq3u41ctia9e6i3tbnlstn6ek739vpke@4ax.com>
POV 3.5 b 9.icl on PII 233 128 MB with NT 4 Sp 6

documentation says about spline specification

#declare IDENTIFIER =spline { [SPLINE_IDENTIFIER]  [SPLINE_TYPE] ...

So identifier and type are both optional but can be together.

I checked that when spline S1 is declared and I declare spline S2 as "child" of
S1 but with different type then type declaration is parsed ok but do nothing.
But is is parsed ok so I don't know what is wrong parser, documentation or
engine. Conversion is definetly possible becouse when I force type in spline
calculation instead of definition then it is changed ok.
Below is test scene. Working with it I noticed another bug. I can't pass spline
calculation as macro parameter. To check it uncomment debug line. Works fine
when there is parenthesis around spline in call of VStr().
Playing with it I found also small feature request. I'll send it to p.general.

#version 3.5;

#include "stdinc"

global_settings {
  assumed_gamma 1.0
}

camera {
  location <0,.5,-4>
  direction 1.5*z
  right x*image_width/image_height
  look_at 0
}

light_source {30*<-1,1,-1> color rgb 1}

background{1}

#declare Points=10;
#declare Radius=.1;
#declare Step=.1;

#macro Force()
  #if(force_cubic)
    ,cubic_spline
  #end
#end

#macro Draw(Spline,T,force_cubic) // let's draw spline
  union{
    #local c=1;
    #while (c<=(Points-Step))
//      #debug concat(Str(c)," - ",VStr(Spline(c)),"\n")
      sphere{Spline(c Force()) Radius}
      cylinder{Spline(c Force()),Spline(c+Step Force()),Radius}
      #local c=c+Step;
    #end
    sphere{Spline(Points Force()) Radius}
    pigment{color rgb 1}
    scale .2
    translate T*<.7,.5,1>
  }
#end

#macro List() // makes list of points for spline
  #local G=seed(0);
  #local c=1;
  #while (c<=Points)
    c,2*<rand(G),rand(G),rand(G)>-1
    #local c=c+1;
  #end
#end

#local S1=spline{linear_spline List()}     // works as expected
#local S2=spline{cubic_spline  List()}     // works as expected

#local S1a=spline{S1 cubic_spline  List()} // type do nothing
#local S2a=spline{S2 linear_spline List()} // type do nothing

#local S1b=spline{S1 cubic_spline }        // type do nothing
#local S2b=spline{S2 linear_spline}        // type do nothing

#local S1c=spline{S1 3,2*y}                // works as expected
#local S2c=spline{S2 3,2*y}                // works as expected

Draw( S1  ,-2*x+y , no )
Draw( S2  ,-2*x-y , no )
Draw( S1a ,  -x+y , no )
Draw( S2a ,  -x-y , no )
Draw( S1b ,   0+y , no )
Draw( S2b ,   0-y , no )
Draw( S1c ,   x+y , no )
Draw( S2c ,   x-y , no )
Draw( S1c , 2*x+y , yes)
Draw( S2c , 2*x-y , yes)

// ABX


Post a reply to this message

From:
Subject: Re: splines - documentation and reality
Date: 10 Jan 2002 05:25:34
Message: <bqqq3ukvqrhpig97ndfi1du3k3k60lf9c5@4ax.com>

wrote:
> #local S1c=spline{S1 3,2*y}                // works as expected
> #local S2c=spline{S2 3,2*y}                // works as expected

also please note documentation not precise (in 6.1.9)
how parser behaves in above situation.

ABX


Post a reply to this message

From: ingo
Subject: Re: splines - documentation and reality
Date: 10 Jan 2002 07:55:51
Message: <Xns91928DF07F1C6seed7@povray.org>

wrote:

> documentation says about spline specification
> 
> #declare IDENTIFIER =spline { [SPLINE_IDENTIFIER]  [SPLINE_TYPE] ...
> 
> So identifier and type are both optional but can be together.
> 

The way I interpreted the changing of the spline type is that is is only 
possible when you retreive one value from the spline.

#declare P1=<0,0,0>+Spline(1,linear_spline);

Not for copying a spline. I agree that in that case the syntax section 
is not clear, is adding a pipe enough:

#declare IDENTIFIER =
  spline { 
    [SPLINE_IDENTIFIER] |
    [SPLINE_TYPE] 
    ...

Then again, the current spline implementation is marked experimental and 
has several bugs, so I'm not sure how it should/will work and what to 
change in the docs. I'll put your remark in the todo list and wait for a 
more final spline before changing the docs.


Ingo


Post a reply to this message

From: Mark Wagner
Subject: Re: splines - documentation and reality
Date: 12 Jan 2002 00:13:16
Message: <3c3fc5ec@news.povray.org>

>documentation says about spline specification
>
>#declare IDENTIFIER =spline { [SPLINE_IDENTIFIER]  [SPLINE_TYPE] ...
>
>So identifier and type are both optional but can be together.
>
>I checked that when spline S1 is declared and I declare spline S2 as
"child" of
>S1 but with different type then type declaration is parsed ok but do
nothing.
>But is is parsed ok so I don't know what is wrong parser, documentation or
>engine. Conversion is definetly possible becouse when I force type in
spline
>calculation instead of definition then it is changed ok.
>Below is test scene.

This should work, and doesn't.  For those of you who are working on the
official source code, the fix is the following changes to Parse_Spline in
express.cpp:

Replace
   EXPECT/*Check for spline identifier*/
     CASE(SPLINE_ID_TOKEN)
       New = Copy_Spline((SPLINE *)Token.Data);
       i = New->Number_Of_Entries;
       EXIT
     END_CASE

     OTHERWISE
       UNGET

       EXIT
     END_CASE
   END_EXPECT

with
   EXPECT/*Check for spline identifier*/
     CASE(SPLINE_ID_TOKEN)
       New = Copy_Spline((SPLINE *)Token.Data);
       i = New->Number_Of_Entries;
       Type = New->Type;
       EXIT
     END_CASE

     OTHERWISE
       UNGET

       EXIT
     END_CASE
   END_EXPECT

and add
   New->Type = Type;
just before the line
return New;

>Working with it I noticed another bug. I can't pass spline
>calculation as macro parameter. To check it uncomment debug line. Works
fine
>when there is parenthesis around spline in call of VStr().


This is a known problem.  I'm fairly sure it is officially classified as a
"feature", and putting parentheses around the spline is the recommended
work-around.

--
Mark


Post a reply to this message

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