POV-Ray : Newsgroups : povray.general : L-Systems in Povray : Re: L-Systems in Povray Server Time
24 Apr 2024 19:22:15 EDT (-0400)
  Re: L-Systems in Povray  
From: ingo
Date: 7 Jun 2023 00:55:00
Message: <web.64800d44453cebfc17bac71e8ffb8ce3@news.povray.org>
"Droj" <803### [at] drojde> wrote:

> I feel like Ingo got me by the 'short hair':


Pos is an 'abused' vector. <x,y,angle>. Instead I could have used:
#local Pos2D = <x, y>;
#local Angle = 25;

Now angle and location are separated.

So
#macro F(Pos)
  <Pos.x + cos(Pos.z), Pos.y + sin(Pos.z), Pos.z> // <x, y, angle>
#end
#declare BuildRules["F"] = 70; //chr(70) = F

becomes

#macro F(Pos, Angle)
  <Pos2D.x + cos(Angle), Pos2D.y + sin(Angle)> // <x, y>
  //the angle is fixed
#end
#declare BuildRules["F"] = 70; //chr(70) = F



#macro Plus(Pos)
  <Pos.x, Pos.y, Pos.z + (pi/2)>
#end
#declare BuildRules["+"] = 43;

#macro Plus(Angle)
  Angle + (pi/2)
#end
#declare BuildRules["+"] = 43;


And
    #ifdef (BuildRules[CurrentSymbol])
      #switch (BuildRules[CurrentSymbol])
        #case(70)
          #local Pos = F(Pos);
        #break
        #case(43)
          #local Pos = Plus(Pos);
        #break

becomes

    #ifdef (BuildRules[CurrentSymbol])
      #switch (BuildRules[CurrentSymbol])
        #case(70)
          #local Pos = F(Pos, Angle);
        #break
        #case(43)
          #local Pos = Plus(Angle);
        #break


now the Pos vector and angle are separated. The next step is to turn them into
3D vectors. You can use a 3D vector for the three angles too.
(untested code)


Post a reply to this message

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