POV-Ray : Newsgroups : povray.general : Spline Sweep / While: The Tragedy of the Last Comma Server Time: 26 Jun 2019 10:17:01 GMT
  Spline Sweep / While: The Tragedy of the Last Comma (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Sven Littkowski
Subject: Spline Sweep / While: The Tragedy of the Last Comma
Date: 23 Feb 2018 20:50:35
Message: <5a907e9b@news.povray.org>
What smart ways do you know of, to add or not add the comma for each
spline sweet element but the last one?

This is what I tried, but I fail...
----------------------

sphere_sweep
{
 b_spline
 MySegmentAmount,
 #while (MyCount <= MySegmentAmount)
  #if(MyCount=MySegmentAmount)
   #declare MyComma="";
  #else
   #declare MyComma=",";
  #end
  < MyX, MyY, MyZ >, 0.35 MyComma
  #declare MyY             = MyY+MyVMovement;
  #declare MyX             = rand(MySeed)*MyHMovement;
  #declare MyZ             = rand(MySeed)*MyHMovement;
  #declare MyXNegative     = rand(MySeed)*1.0;
  #declare MyZNegative     = rand(MySeed)*1.0;
  #if(MyXNegative<=0.5)
   #declare MyX=MyX*(-1.0);
  #end
  #if(MyZNegative<=0.5)
   #declare MyZ=MyZ*(-1.0);
  #end
  #declare MyCount=MyCount+1;
 #end
 tolerance 0.1
 ...

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: dick balaska
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 23 Feb 2018 21:24:26
Message: <5a90868a$1@news.povray.org>
On 02/23/2018 03:50 PM, Sven Littkowski wrote:
> What smart ways do you know of, to add or not add the comma for each
> spline sweet element but the last one?
> 
> This is what I tried, but I fail...

 >   < MyX, MyY, MyZ >, 0.35 MyComma

The example shows no comma at all in that position
http://www.povray.org/documentation/view/3.7.1/63/

-- 
dik
Rendered 920576 of 921600 pixels (99%)


Post a reply to this message

From: Sven Littkowski
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 23 Feb 2018 21:38:29
Message: <5a9089d5$1@news.povray.org>
I used the INSERTR feature of the POV-Ray editor. There, there are
commas behind each line but the last line. And without comma, i am
getting an error, too.

sphere_sweep {
    b_spline
    6,
    < 0.50, 1.00, 0>, 0.35,
    <-0.50, 1.00, 0>, 0.25,
    <-0.50, 0.00, 0>, 0.15,
    < 0.50, 0.00, 0>, 0.25,
    < 0.50, 1.00, 0>, 0.15,
    <-0.50, 1.00, 0>, 0.10
    tolerance 0.1

    texture{ pigment{ color rgb<0.69,0.99,0.15>}
             finish { phong 1 }
           } // end of texture

    scale<1,1,1>   rotate<0,0,0>  translate<0,0.5,0>
   }  // end of sphere_sweep ----------------------------





On 23.02.2018 16:24, dick balaska wrote:
> The example shows no comma at all in that position
> http://www.povray.org/documentation/view/3.7.1/63/




---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: dick balaska
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 23 Feb 2018 21:50:47
Message: <5a908cb7$1@news.povray.org>
On 02/23/2018 04:38 PM, Sven Littkowski wrote:
> I used the INSERTR feature of the POV-Ray editor. There, there are
> commas behind each line but the last line. And without comma, i am
> getting an error, too.

This works fine for me:

sphere_sweep {
     b_spline
     6,
     < 0.50, 1.00, 0>, 0.35
     <-0.50, 1.00, 0>, 0.25
     <-0.50, 0.00, 0>, 0.15
     < 0.50, 0.00, 0>, 0.25
     < 0.50, 1.00, 0>, 0.15
     <-0.50, 1.00, 0>, 0.10
     tolerance 0.1

     texture{ pigment{ color rgb<0.69,0.99,0.15>}
              finish { phong 1 }
            } // end of texture

     scale<1,1,1>   rotate<0,0,0>  translate<0,0.5,0>
    }  // end of sphere_sweep ----------------------------



-- 
dik
Rendered 920576 of 921600 pixels (99%)


Post a reply to this message

From: dick balaska
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 23 Feb 2018 22:09:55
Message: <5a909133$1@news.povray.org>
On 02/23/2018 03:50 PM, Sven Littkowski wrote:

> This is what I tried, but I fail...
> ----------------------
> 
> sphere_sweep
> {
>   b_spline
>   MySegmentAmount,
>   #while (MyCount <= MySegmentAmount)
>    #if(MyCount=MySegmentAmount)
>     #declare MyComma="";
>    #else
>     #declare MyComma=",";
>    #end
>    < MyX, MyY, MyZ >, 0.35 MyComma


Are you initializing MyCount = 1; ?

-- 
dik
Rendered 920576 of 921600 pixels (99%)


Post a reply to this message

From: Alain
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 24 Feb 2018 03:28:31
Message: <5a90dbdf$1@news.povray.org>
Le 18-02-23 à 15:50, Sven Littkowski a écrit :
> What smart ways do you know of, to add or not add the comma for each
> spline sweet element but the last one?
> 

If you are confident that you never have negative radius, you can 
completely do away with the comas.

General rule : Comas are optional in all cases where the separation 
between consecutive values is unambiguous. The only case where it can be 
ambiguous is the case of a negative value that will be interpreted as an 
operation.

1 1 1 is equivalent to 1,1,1
1, -1 1 is OK, but 1 -1 1 will be interpreted as (1-1) 1 or 0 1

Alain


Post a reply to this message

From: clipka
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 24 Feb 2018 09:39:01
Message: <5a9132b5$1@news.povray.org>
Am 23.02.2018 um 21:50 schrieb Sven Littkowski:
> What smart ways do you know of, to add or not add the comma for each
> spline sweet element but the last one?
> 
> This is what I tried, but I fail...
> ----------------------
> 
> sphere_sweep
> {
>  b_spline
>  MySegmentAmount,
>  #while (MyCount <= MySegmentAmount)
>   #if(MyCount=MySegmentAmount)
>    #declare MyComma="";

You could use

     #macro MyComma() #end

>   #else
>    #declare MyComma=",";

     #macro MyComma() , #end

>   #end
>   < MyX, MyY, MyZ >, 0.35 MyComma

                            MyComma()

>   #declare MyY             = MyY+MyVMovement;
...

However, it would be much easier to use

    sphere_sweep {
      b_spline
      MySegmentAmount // no comma here!
      #while (...)
        ...
        , <MyX, MyY, MyZ>, 0.35
        ...
      #end
      ...
    }

Also, modern versions do allow a "dangling" comma by now:

    #version 3.71;
    sphere_sweep {
      b_spline
      MySegmentAmount,
      #while (...)
        ...
        <MyX, MyY, MyZ>, 0.35,
        ...
      #end
      ...
    }


Post a reply to this message

From: Sven Littkowski
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 25 Feb 2018 05:29:23
Message: <5a9249b3$1@news.povray.org>
Still getting errors. Here's the relevant code:
--------------------------


#declare MySeed          = seed(now*24*60*60);
#declare MySegmentAmount = 0; // just to initialize
#while(MySegmentAmount<10)    // I need a minimum of 10 items
 #declare MySegmentAmount = int(rand(MySeed)*75);
#end
#declare MyHMovement     = 0.75;
#declare MyVMovement     = 0.5;
#declare MyY             = 0.0;
#declare MyX             = rand(MySeed)*MyHMovement;
#declare MyZ             = rand(MySeed)*MyHMovement;
#declare MyXNegative     = rand(MySeed)*1.0;
#declare MyZNegative     = rand(MySeed)*1.0;
#declare MyCount         = 0;
#if(MyXNegative<=0.5)
 #declare MyX=MyX*(-1.0);
#end
#if(MyZNegative<=0.5)
 #declare MyZ=MyZ*(-1.0);
#end

sphere_sweep
{
 b_spline
 MySegmentAmount,
 #while (MyCount<=MySegmentAmount)
  < MyX, MyY, MyZ > 0.35
  #declare MyY             = MyY+MyVMovement;
  #declare MyX             = rand(MySeed)*MyHMovement;
  #declare MyZ             = rand(MySeed)*MyHMovement;
  #declare MyXNegative     = rand(MySeed)*1.0;
  #declare MyZNegative     = rand(MySeed)*1.0;
  #if(MyXNegative<=0.5)
   #declare MyX=MyX*(-1.0);
  #end
  #if(MyZNegative<=0.5)
   #declare MyZ=MyZ*(-1.0);
  #end
  #declare MyCount=MyCount+1;
 #end
 tolerance 0.1
 texture
 {
  pigment
  {
   onion
   color_map
   {
    [ 0.0 color rgbf < 0.2352941,  0.1607843,  0.1568627, 0.5 > ]
    [ 1.0 color rgbf < 0.2352941,  0.1607843,  0.1568627, 0.5 > ]
   }
   rotate < 0, 0, 90 >
   scale 0.6
  }
  normal
  {
   granite 0.15
   scale 1
  }
  finish { phong 0.1 }
 }
 scale<1,1,1>   rotate<0,0,0>  translate<0,0.5,0>
 rotate < -90.0, 0.0, 0.0 >
 translate < 0.0, 0.0, 0.0 >
 scale < 0.015,0.05,0.015 >
}


---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Sven Littkowski
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 25 Feb 2018 08:16:30
Message: <5a9270de$1@news.povray.org>
Still getting errors. Here's the entire scene code:
-----------------------------

// ABX  Place and orient objects along spline
http://news.povray.org/povray.general/message/%3Cttoenucoq6fcgkun57la24s9ia
4ij5o573%404ax.com%3E/#%3Cttoenucoq6fcgkun57la24s9ia4ij5o573%404ax.com%3E

#version 3.7;

#declare RAD = 4;

global_settings
{
 #declare a_g = 1;
 assumed_gamma a_g
 max_trace_level 5
 subsurface {radiosity on samples 200,200}
 noise_generator 2
 #if(RAD > 0)
  radiosity
  {
   pretrace_start 0.08
   pretrace_end   0.04/RAD
   count 60*RAD
   nearest_count min (20, RAD)
   error_bound 2/RAD
   low_error_factor 0.5
   recursion_limit 1
   gray_threshold 0
   minimum_reuse 0.015
   brightness 1
   adc_bailout 0.005
   normal on
   media off
   always_sample off
  }
 #end
}

camera
{
 angle 31*image_width/image_height*0.75
 location  < 0, 1, -2 >
 right     x*image_width/image_height
 look_at   < 0, 0.05, 0 >
}


#declare MySeed          = seed(now*24*60*60);
#declare MySegmentAmount = 0;
#while(MySegmentAmount<10)
 #declare MySegmentAmount = int(rand(MySeed)*75);
#end
#declare MyHMovement     = 0.75;
#declare MyVMovement     = 0.5;
#declare MyY             = 0.0;
#declare MyCount         = 0;

sphere_sweep
{
 b_spline
 MySegmentAmount,
 #while (MyCount<=MySegmentAmount)
  #declare MyY             = MyY+MyVMovement;
  #declare MyX             = rand(MySeed)*MyHMovement;
  #declare MyZ             = rand(MySeed)*MyHMovement;
  #declare MyXNegative     = rand(MySeed)*1.0;
  #declare MyZNegative     = rand(MySeed)*1.0;
  #if(MyXNegative<=0.5)
   #declare MyX=MyX*(-1.0);
  #end
  #if(MyZNegative<=0.5)
   #declare MyZ=MyZ*(-1.0);
  #end
  < MyX, MyY, MyZ > 0.35
  #declare MyCount=MyCount+1;
 #end
 tolerance 0.1
 texture
 {
  pigment
  {
   onion
   color_map
   {
    [ 0.0 color rgbf < 0.2352941,  0.1607843,  0.1568627, 0.5 > ]
    [ 1.0 color rgbf < 0.2352941,  0.1607843,  0.1568627, 0.5 > ]
   }
   rotate < 0, 0, 90 >
   scale 0.6
  }
  normal
  {
   granite 0.15
   scale 1
  }
  finish { phong 0.1 }
 }
 scale<1,1,1>   rotate<0,0,0>  translate<0,0.5,0>
 rotate < -90.0, 0.0, 0.0 >
 translate < 0.0, 0.0, 0.0 >
 scale < 0.015,0.05,0.015 >
}

plane
{
 y, -0.0
 pigment { color rgb < 0.1882353,  0.2705882,  0.3294118 >*0.1 }
}

sphere
{
 0, 1000
 pigment
 {
  image_map
  {
   hdr "C:\Users\Sven
Littkowski\Documents\POV-Ray\v3.7\scenes\r\kitchen_probe2.hdr"
   gamma 2.2
   map_type 1
   interpolate 2
  }
 }
 finish {emission rgb 0.05}
 no_image
}

background
{
 color rgb < 0.1882353,  0.2705882,  0.3294118 >*0.1
}

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: clipka
Subject: Re: Spline Sweep / While: The Tragedy of the Last Comma
Date: 25 Feb 2018 10:26:36
Message: <5a928f5c$1@news.povray.org>
Am 25.02.2018 um 09:16 schrieb Sven Littkowski:

> #declare MyCount         = 0;
> 
> sphere_sweep
> {
>  b_spline
>  MySegmentAmount,

You're promising to provide MySegmentAmount control points, ...

>  #while (MyCount<=MySegmentAmount)

...but With MyCount starting at 0, this loop is executed
MySegmentAmount+1 times, giving you one control point too many.


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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