POV-Ray : Newsgroups : povray.general : L-Systems in Povray Server Time
27 Jul 2024 18:28:40 EDT (-0400)
  L-Systems in Povray (Message 41 to 50 of 64)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: ingo
Subject: Re: L-Systems in Povray
Date: 11 Jul 2023 01:05:00
Message: <web.64ace273453cebfc17bac71e8ffb8ce3@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
>
> > in Lvertices(), the for loop needs to read '#for (i,1,strlen(Lstr))'.  then the
> > problem becomes that you have no 'BuildRules' key for 'X', yet.  hth.
>
> So, I added:
>
> #declare BuildRules["X"] = asc("X");


The #switch needs an #else and do nothing there, for all symbols that do not
have a build rule, such as 'X' in this case


Regarding muses, besides shaving, although she prefers photography, point your
attention to the 'muse with the glass eye'. She likes ray tracing too.

ingo


Post a reply to this message

From: jr
Subject: Re: L-Systems in Povray
Date: 11 Jul 2023 06:55:00
Message: <web.64ad3482453cebfcb49d80446cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> ...
> I have NO idea what I'm doing, but that gets me a completed render and no
> crashing.

_neat_.  (and thanks, that'll give me .. encouragement to play a little more
:-))


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: L-Systems in Povray
Date: 11 Jul 2023 13:20:00
Message: <web.64ad8ef9453cebfc1f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > ...
> > I have NO idea what I'm doing, but that gets me a completed render and no
> > crashing.
>
> _neat_.  (and thanks, that'll give me .. encouragement to play a little more
> :-))
>
>
> regards, jr.

Other changes:

#declare BuildRules["X"] = asc("X"); // 88

#debug concat( "X = ", str(asc("X"), 0, 0), "\n")

#macro MoveRight (T_Pos)
 <T_Pos.x + 1, T_Pos.y, T_Pos.z>
 //#local T_Pos = <T_Pos.x + 1, T_Pos.y, T_Pos.z>;
 //#declare VXY_Arr[Curr_Items] = T_Pos;
 //#declare AZZ_Arr[Curr_Items] = AngleZZ;
 //#declare Curr_Items = Curr_Items + 1;
#end

    #case (88)
    #local T_Pos = MoveRight (T_Pos);
    #break

    #else
    #break
   #end // end switch


#declare Axiom = "FFFFX";
#declare Rules = dictionary {
  ["X"] : "F[-X|][+F|]",
 // ["Y"] : "FX-Y"
}

#declare Iterations = 50;


Doesn't get me much, except a few line segments.  Once I have more time to
decipher the Big Picture, then it will be easier to make things work.


Post a reply to this message


Attachments:
Download 'lsys7.pov.txt' (5 KB)

From: Droj
Subject: Re: L-Systems in Povray
Date: 12 Jul 2023 10:10:00
Message: <web.64aeb317453cebfcdec7f1e73b2af915@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > hi,
> >
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > ...
> > > I have NO idea what I'm doing, but that gets me a completed render and no
> > > crashing.
> >
> > _neat_.  (and thanks, that'll give me .. encouragement to play a little more
> > :-))
> >
> >
> > regards, jr.
>
> Other changes:
>
> #declare BuildRules["X"] = asc("X"); // 88
>
> #debug concat( "X = ", str(asc("X"), 0, 0), "\n")
>
> #macro MoveRight (T_Pos)
>  <T_Pos.x + 1, T_Pos.y, T_Pos.z>
>  //#local T_Pos = <T_Pos.x + 1, T_Pos.y, T_Pos.z>;
>  //#declare VXY_Arr[Curr_Items] = T_Pos;
>  //#declare AZZ_Arr[Curr_Items] = AngleZZ;
>  //#declare Curr_Items = Curr_Items + 1;
> #end
>
>     #case (88)
>     #local T_Pos = MoveRight (T_Pos);
>     #break
>
>     #else
>     #break
>    #end // end switch
>
>
> #declare Axiom = "FFFFX";
> #declare Rules = dictionary {
>   ["X"] : "F[-X|][+F|]",
>  // ["Y"] : "FX-Y"
> }
>
> #declare Iterations = 50;
>



>
> Doesn't get me much, except a few line segments.  Once I have more time to
> decipher the Big Picture, then it will be easier to make things work.

Hi,

first of all thanks to all of you for your engagement to solve this 'mystery'.

Just one remark: please do not use 'Iterations = 50;'. If the coding works
properly Povray will produce an amount of data to choke a horse with.

As far as using "X" or "Y" without declaring it is concerned: I used Ingo's
original code - means vector and angle are not separated - with

#declare Axiom = "X";
#declare Rules = dictionary{
  ["X"] : "XFYFX+F+YFXFY-F-XFYFX",
  ["Y"] : "YFXFY-F-XFYFX+F+YFXFY"
}
and it works like a charm (see attachment).

Furthermore I used Ingo's original and added Push and Pop stacks and...
Povray again complained about (vertices).
Could it be that Povray hates LIFO arrays <grin>.

Can't wait until Ingo's 'muse with the glass eye' is kissing me - I AM cleanly
shaven.

Time to investigate further.

Regards
Droj


Post a reply to this message


Attachments:
Download 'lsys3.pov.txt' (3 KB)

From: Droj
Subject: Re: L-Systems in Povray
Date: 12 Jul 2023 13:00:00
Message: <web.64aedbb5453cebfc763e4a273b2af915@news.povray.org>
"Droj" <803### [at] drojde> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > "jr" <cre### [at] gmailcom> wrote:
> > > hi,
> > >
> > > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > > ...
> > > > I have NO idea what I'm doing, but that gets me a completed render and no
> > > > crashing.
> > >
> > > _neat_.  (and thanks, that'll give me .. encouragement to play a little more
> > > :-))
> > >
> > >
> > > regards, jr.
> >
> > Other changes:
> >
> > #declare BuildRules["X"] = asc("X"); // 88
> >
> > #debug concat( "X = ", str(asc("X"), 0, 0), "\n")
> >
> > #macro MoveRight (T_Pos)
> >  <T_Pos.x + 1, T_Pos.y, T_Pos.z>
> >  //#local T_Pos = <T_Pos.x + 1, T_Pos.y, T_Pos.z>;
> >  //#declare VXY_Arr[Curr_Items] = T_Pos;
> >  //#declare AZZ_Arr[Curr_Items] = AngleZZ;
> >  //#declare Curr_Items = Curr_Items + 1;
> > #end
> >
> >     #case (88)
> >     #local T_Pos = MoveRight (T_Pos);
> >     #break
> >
> >     #else
> >     #break
> >    #end // end switch
> >
> >
> > #declare Axiom = "FFFFX";
> > #declare Rules = dictionary {
> >   ["X"] : "F[-X|][+F|]",
> >  // ["Y"] : "FX-Y"
> > }
> >
> > #declare Iterations = 50;
> >
>
>
>
> >
> > Doesn't get me much, except a few line segments.  Once I have more time to
> > decipher the Big Picture, then it will be easier to make things work.
>
> Hi,
>
> first of all thanks to all of you for your engagement to solve this 'mystery'.
>
> Just one remark: please do not use 'Iterations = 50;'. If the coding works
> properly Povray will produce an amount of data to choke a horse with.
>
> As far as using "X" or "Y" without declaring it is concerned: I used Ingo's
> original code - means vector and angle are not separated - with
>
> #declare Axiom = "X";
> #declare Rules = dictionary{
>   ["X"] : "XFYFX+F+YFXFY-F-XFYFX",
>   ["Y"] : "YFXFY-F-XFYFX+F+YFXFY"
> }
> and it works like a charm (see attachment).
>
> Furthermore I used Ingo's original and added Push and Pop stacks and...
> Povray again complained about (vertices).
> Could it be that Povray hates LIFO arrays <grin>.
>
> Can't wait until Ingo's 'muse with the glass eye' is kissing me - I AM cleanly
> shaven.
>
> Time to investigate further.
>
> Regards
> Droj

Just in case you are curious how lsys3.pov looks like.


Post a reply to this message


Attachments:
Download 'lsys3.png' (149 KB)

Preview of image 'lsys3.png'
lsys3.png


 

From: ingo
Subject: Re: L-Systems in Povray
Date: 12 Jul 2023 13:05:00
Message: <web.64aedcd4453cebfc17bac71e8ffb8ce3@news.povray.org>
"Droj" <803### [at] drojde> wrote:

worked a bit on you lsys7. Simplified a few minor things. Changed a bit in
LVertices and added debugging.

We're at "Parse Error: Expected 'RValue to declare', End of File found instead"
now.

ingo


---%<---------%<---------%<---
/*Pov-Ray    : 3.8
Scene File : lsys.pov
Author     : Ingo Janssen
Date       : 2023-06-04
*/
#version 3.8;

global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }}

#declare T_Pos = <0, 0, 0>;
#declare A_F = 14; // Angle increment
#declare Max_Items = 200;
#declare Curr_Items = 0;
#declare VXY_Arr = array[Max_Items]; // Pos stack for xy-plane
#declare AZZ_Arr = array[Max_Items]; // Angle stack for xy-plane


//build rules
#declare BuildRules = dictionary;


#macro F(T_Pos, AngleZZ)
 #local T_Pos = <0, 0, 0>;
    <T_Pos.x + cos(AngleZZ), T_Pos.y + sin(AngleZZ), T_Pos.z> // <x, y, 0>
#end
#declare BuildRules["F"] = 70; //chr(70) = F


#macro YawR(AngleZZ)
 #local AngleZZ = 0;
  AngleZZ + (tau/A_F)
#end
#declare BuildRules["+"] = 43;


#macro YawL(AngleZZ)
 #local AngleZZ = 0;
  AngleZZ - (tau/A_F)
#end
#declare BuildRules["-"] = 45;


#macro Turn(AngleZZ)
 #local AngleZZ = 0;
   AngleZZ - (tau/2)
#end
#declare BuildRules["|"] = 124;


// the following macros are needed for branching
#macro Push(T_Pos, AngleZZ)
  #declare VXY_Arr[Curr_Items] = T_Pos;
  #declare AZZ_Arr[Curr_Items] = AngleZZ;
  #declare Curr_Items = Curr_Items + 1;
#end
#declare BuildRules["["] = 91;


#macro Pop(T_Pos, AngleZZ)
  #declare Curr_Items = Curr_Items - 1;
  #declare T_Pos = VXY_Arr[Curr_Items];
  #declare AngleZZ = AZZ_Arr[Curr_Items];
#end
#declare BuildRules["]"] = 93;

//

// I left Ingo's brilliant rewrite macro untouched
#macro Ltransform(Axiom, Rules, Iterations)
  #local Result = Axiom;
  #for (i, 1, Iterations)
      #local NewResult = "";
      #local N = strlen(Result);
      #local j = 1;
      #while (j <= N)
        #local CurrentSymbol = substr(Result, j, 1);
        #ifdef(Rules[CurrentSymbol])
          #local NewResult = concat(NewResult, Rules[CurrentSymbol]);
        #else
          #local NewResult = concat(NewResult, CurrentSymbol);
        #end
        #local j = j + 1;
      #end
      #local Result = NewResult;
      #debug concat(Result, "\n")
  #end
  Result
#end


#macro Lvertices(Lstr)
  #local T_Pos = <0, 0, 0>; // <x, y, z>
  #local AngleZZ = 0;
  //#local Curr_Item = 0;
  #declare Return = array; //{<T_Pos.x, T_Pos.y, T_Pos.z>};
 #declare Return[0] = <T_Pos.x, T_Pos.y, T_Pos.z>;
  #for (i, 0, strlen(Lstr)-1)
    #local CurrentSymbol = substr(Lstr, i, 1);
    #ifdef (BuildRules[CurrentSymbol])
      #switch (BuildRules[CurrentSymbol])
        #case(70)
          #debug "70 F \n"
          #local T_Pos = F(T_Pos, AngleZZ);
        #break
        #case(43)
          #debug "43 + \n"
          #local AngleZZ = YawR(AngleZZ);
        #break
        #case(45)
          #debug "45 - \n"
          #local AngleZZ = YawL(AngleZZ);
        #break
        #case(124)
          #debug "124 | \n"
          #local AngleZZ = Turn(AngleZZ);
        #break

        #case(91)
          #debug "91 [ \n"
          #local Curr_Item = Push(T_Pos, AngleZZ);
        #break


        #case(93)
          #debug "93 ] \n"
          #local Curr_Item = Pop(T_Pos, AngleZZ);
        #break

      #end
      #local InArr = Return[dimension_size(Return,1)-1];
      #if (T_Pos.x != InArr.x | T_Pos.y != InArr.y | T_Pos.z != InArr.z)
        #declare Return[dimension_size(Return,1)] = <T_Pos.x, T_Pos.y, T_Pos.z>;
      #end
    #end
  #end
  #declare Vertices = Return;
  Vertices
#end

#declare Axiom = "FFFFX";
#declare Rules = dictionary{
  ["X"] : "F[-FX][+FX]",
  ["Y"] : "FX-Y"
};
#declare Iterations = 1;

#declare Lstr = Ltransform(Axiom, Rules, Iterations);

#declare Vertices = Lvertices(Lstr);

/*
#ifdef (Vertices)
 #debug "OK \n"
#else
 #debug "Undefined! \n"
#end
*/
/*#for(i, 0, dimension_size(Vertices,1)-2) // <== here Povray complains
  cylinder{
    Vertices[i],Vertices[i+1],0.1
    texture{pigment{rgb 1}}
    translate <-25, -5, 0>
    rotate <0, 0, 0>
  }
#end*/

camera{
  location <0,0,-30>
  look_at <0,0,0>
  angle 120
  right x*image_width/image_height
}

light_source{
  <3000,3000,-3000>
  color rgb 1
}
---%<---------%<---------%<---


Post a reply to this message

From: ingo
Subject: Re: L-Systems in Povray
Date: 12 Jul 2023 13:15:00
Message: <web.64aedf3b453cebfc17bac71e8ffb8ce3@news.povray.org>
"ingo" <nomail@nomail> wrote:

>
> #macro Lvertices(Lstr)
>   #local T_Pos = <0, 0, 0>; // <x, y, z>
>   #local AngleZZ = 0;
>   //#local Curr_Item = 0;
>   #declare Return = array; //{<T_Pos.x, T_Pos.y, T_Pos.z>};
>  #declare Return[0] = <T_Pos.x, T_Pos.y, T_Pos.z>;
>   #for (i, 0, strlen(Lstr)-1) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>     #local CurrentSymbol = substr(Lstr, i, 1);
>     #ifdef (BuildRules[CurrentSymbol])
>       #switch (BuildRules[CurrentSymbol])
>         #case(70)
>           #debug "70 F \n"
>           #local T_Pos = F(T_Pos, AngleZZ);
>         #break
>         #case(43)
>           #debug "43 + \n"
>           #local AngleZZ = YawR(AngleZZ);
>         #break
>         #case(45)
>           #debug "45 - \n"
>           #local AngleZZ = YawL(AngleZZ);
>         #break
>         #case(124)
>           #debug "124 | \n"
>           #local AngleZZ = Turn(AngleZZ);
>         #break
>
>         #case(91)
>           #debug "91 [ \n"
>           #local Curr_Item = Push(T_Pos, AngleZZ);
>         #break
>
>
>         #case(93)
>           #debug "93 ] \n"
>           #local Curr_Item = Pop(T_Pos, AngleZZ);
>         #break
>
>       #end
>       #local InArr = Return[dimension_size(Return,1)-1];
>       #if (T_Pos.x != InArr.x | T_Pos.y != InArr.y | T_Pos.z != InArr.z)
>         #declare Return[dimension_size(Return,1)] = <T_Pos.x, T_Pos.y, T_Pos.z>;
>       #end
>     #end
>   #end
>   #declare Vertices = Return;
>   Vertices
> #end

  try: #for (i, 0, strlen(Lstr)) in the macro. The it runs and renders a small
white stick? But with Iterations = 2 it fails.

ingo


Post a reply to this message

From: ingo
Subject: Re: L-Systems in Povray
Date: 12 Jul 2023 14:15:00
Message: <web.64aeeca8453cebfc17bac71e8ffb8ce3@news.povray.org>
Try this.
Your pop and push macros didn't return anything.
image looks strange.

ingo

/*Pov-Ray    : 3.8
Scene File : lsys.pov
Author     : Ingo Janssen
Date       : 2023-06-04
*/
#version 3.8;

global_settings{ assumed_gamma 1.0 }
#default{ finish{ ambient 0.1 diffuse 0.9 }}

#declare T_Pos = <0, 0, 0>;
#declare A_F = 14; // Angle increment
#declare Max_Items = 200;
//#declare Curr_Items = 0;
#declare VXY_Arr = array[Max_Items]; // Pos stack for xy-plane
#declare AZZ_Arr = array[Max_Items]; // Angle stack for xy-plane


//build rules
#declare BuildRules = dictionary;


#macro F(T_Pos, AngleZZ)
 #local T_Pos = <0, 0, 0>;
    <T_Pos.x + cos(AngleZZ), T_Pos.y + sin(AngleZZ), T_Pos.z> // <x, y, 0>
#end
#declare BuildRules["F"] = 70; //chr(70) = F


#macro YawR(AngleZZ)
 #local AngleZZ = 0;
  AngleZZ + (tau/A_F)
#end
#declare BuildRules["+"] = 43;


#macro YawL(AngleZZ)
 #local AngleZZ = 0;
  AngleZZ - (tau/A_F)
#end
#declare BuildRules["-"] = 45;


#macro Turn(AngleZZ)
 #local AngleZZ = 0;
   AngleZZ - (tau/2)
#end
#declare BuildRules["|"] = 124;


// the following macros are needed for branching
#macro Push(Curr_Item, T_Pos, AngleZZ)
  #debug "push macro runs\n"
  #declare VXY_Arr[Curr_Item] = T_Pos;
  #declare AZZ_Arr[Curr_Item] = AngleZZ;
  #local Curr_Item = Curr_Item + 1;
  Curr_Item
#end
#declare BuildRules["["] = 91;


#macro Pop(Curr_Item, T_Pos, AngleZZ)
  #debug "pop macro runs\n"
  #local Curr_Item = Curr_Item - 1;
  #declare T_Pos = VXY_Arr[Curr_Item];
  #declare AngleZZ = AZZ_Arr[Curr_Item];
  Curr_Item
#end
#declare BuildRules["]"] = 93;

//

// I left Ingo's brilliant rewrite macro untouched
#macro Ltransform(Axiom, Rules, Iterations)
  #local Result = Axiom;
  #for (i, 1, Iterations)
      #local NewResult = "";
      #local N = strlen(Result);
      #local j = 1;
      #while (j <= N)
        #local CurrentSymbol = substr(Result, j, 1);
        #ifdef(Rules[CurrentSymbol])
          #local NewResult = concat(NewResult, Rules[CurrentSymbol]);
        #else
          #local NewResult = concat(NewResult, CurrentSymbol);
        #end
        #local j = j + 1;
      #end
      #local Result = NewResult;
      #debug concat(Result, "\n")
  #end
  Result
#end


#macro Lvertices(Lstr)
  #local T_Pos = <0, 0, 0>; // <x, y, z>
  #local AngleZZ = 0;
  #local Curr_Item = 0;
  #declare Return = array; //{<T_Pos.x, T_Pos.y, T_Pos.z>};
 #declare Return[0] = <T_Pos.x, T_Pos.y, T_Pos.z>;
  #for (i, 0, strlen(Lstr))
    #local CurrentSymbol = substr(Lstr, i, 1);
    #ifdef (BuildRules[CurrentSymbol])
      #switch (BuildRules[CurrentSymbol])
        #case(70)
          #debug "70 F \n"
          #local T_Pos = F(T_Pos, AngleZZ);
        #break
        #case(43)
          #debug "43 + \n"
          #local AngleZZ = YawR(AngleZZ);
        #break
        #case(45)
          #debug "45 - \n"
          #local AngleZZ = YawL(AngleZZ);
        #break
        #case(124)
          #debug "124 | \n"
          #local AngleZZ = Turn(AngleZZ);
        #break
        #case(91)
          #debug "91 [ \n"
          #local Curr_Item = Push(Curr_Item, T_Pos, AngleZZ);
        #break
        #case(93)
          #debug "93 ] \n"
          #local Curr_Item = Pop(Curr_Item, T_Pos, AngleZZ);
        #break
      #end
      #local InArr = Return[dimension_size(Return,1)-1];
      #if (T_Pos.x != InArr.x | T_Pos.y != InArr.y | T_Pos.z != InArr.z)
        #declare Return[dimension_size(Return,1)] = <T_Pos.x, T_Pos.y, T_Pos.z>;
      #end
    #end
  #end
  #declare Vertices = Return;
  Vertices
#end

#declare Axiom = "FFFFX";
#declare Rules = dictionary{
  ["X"] : "F[-FX][+FX]",
  ["Y"] : "FX-Y"
};
#declare Iterations = 6;

#declare Lstr = Ltransform(Axiom, Rules, Iterations);

#declare Vertices = Lvertices(Lstr);


#ifdef (Vertices)
 #debug "OK \n"
#else
 #debug "Undefined! \n"
#end

#for(i, 0, dimension_size(Vertices,1)-2) // <== here Povray complains
  cylinder{
    Vertices[i],Vertices[i+1],0.1
    texture{pigment{rgb 1}}
    translate <-25, -5, 0>
    rotate <0, 0, 0>
  }
#end

camera{
  location <0,0,-30>
  look_at <0,0,0>
  angle 120
  right x*image_width/image_height
}

light_source{
  <3000,3000,-3000>
  color rgb 1
}


Post a reply to this message

From: Droj
Subject: Re: L-Systems in Povray
Date: 12 Jul 2023 16:10:00
Message: <web.64af07a7453cebfc763e4a273b2af915@news.povray.org>
"ingo" <nomail@nomail> wrote:
> Try this.
> Your pop and push macros didn't return anything.
> image looks strange.
>
> ingo
>
Hi,
Gee, I didn't want to open a new rabbit hole for you.

I tried your code and yes: the image DOES look strange.
It seems like the whole thing stops after 1 iteration not knowing where to go
next or what to do next.

But at least Povray does not complain anymore.

I suppose you cannot borrow me your 'muse with the glass eye' for a moment or
two just to find out what's wrong with my push and pop macros.

I promise I'm shaven and like to photograph.

See how this thing we are talking about should look like.

Thanks for your patience

Droj


Post a reply to this message


Attachments:
Download 'ls_plants01.png' (363 KB)

Preview of image 'ls_plants01.png'
ls_plants01.png


 

From: ingo
Subject: Re: L-Systems in Povray
Date: 13 Jul 2023 00:50:00
Message: <web.64af815b453cebfc17bac71e8ffb8ce3@news.povray.org>
"Droj" <803### [at] drojde> wrote:
> I tried your code and yes: the image DOES look strange.
> It seems like the whole thing stops after 1 iteration not knowing where to go
> next or what to do next.
>

Next thing to do is to debug the stack content and the vertices content.

Where it probably goes wrong:
The first point is added to the array and from then on only the "end points"
(last endpoint is next start point). But when branching you need a new start
point. That gets confusing. It is probably better to write [startpoint,
endpoint] to the array. The loop it with a stride of 2.

ingo


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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