I'm working on a fractal tree generating program, and any help would be appreciated. I've isolated these variables:
  • S: initial size of line
  • M: Max iterations
  • I: current iteration
  • R: ratio between S-values in different iterations
  • A: branching angle
  • L1: Branch pathway (this is for DFS-style branch patterning)
  • X: The X-position of the branch end
  • Y: the Y-position of the branch-end

Any help would be greatly appreciated.
The discussion on fractals and recursion in TI-Basic over here may be of interest to you.
So, on further thinking, I'm going to use three lists for this: A, X, & Y. A will be the branching angle relative to the original branch. X& Y will be the branch endpoints, respectively. Since each branching will have an angle of either +A or -A in relation to the previous branch, augment(L₁+A,L₁-A→L₁ will work for that list. For the X & Y lists, something more complicated will be necessary. since I need to preserve the original coordinates for a line( command, and I need to find the new ones, I'll need to use recursive lists; I'll call them B & C.

EDIT

I finally finished a first draft for the code, but I need some help optimizing and adding features. Here's the preliminary

Code:
:ClrHome
:Menu("Input","Seed",A,"Simple",B,"Advanced",C,"Redo Last",D
:Lbl B
:0->Xmin:94->Xmax
:0->Ymin:62->Ymax
:Input "Branching Angle? ",A
:.75->R:17->S:7->M:47->C:0->B
:Goto D
:Lbl A
:rand->E
:Repeat (A>5 and A<175) and (R>.25)
:Input "Seed? ",D
:D->rand
:randInt(0,180->A
:rand->R
:If A≥175 or A≤5 or R≤.25
:Disp "Useless...
:randInt(15,25->S
:End
:7->M
:47->C
:0->B
:Goto D
:Lbl C
:Input "Branching Angle? ",A
:Input "Start Length? ",S
:Input "Ratio? ",R
:Input "Iterations? ",M
:Input "Start X? ",C
:Input "Start Y? ",B
:Lbl D
:B+S->Z
:AxesOff
:ClrDraw
:Line(C,B,C,Z
:{0->L1
:{C->L2
:{Z->L3
:For(I,1,M
:L2->L4
:L3->L5
:augment(L1+A,L1-A->L1
:augment(L2,L2->L2
:augment(L3,L3->L3
:L2+S(R^I)sin(L1->L2
:L3+S(R^I)cos(L1->L3
:For Q,1,dim(L4
:Line(L4(Q),L5(Q),L2(Q),L3(Q)
:Q+dim(L4)
:Line(L4(Q),L5(Q),L2(Ans),L3(Ans
:End
:End
So does this mean you're using a fixed branching factor of 2? Why are you limiting the tree to symmetric branching? Why not support skew, or small random variations?
Please don't create duplicate topics. Keep your discussion here for this project.
What do you mean by branching factor? supporting skew and small variations wouldn't be hard, I can add that in with three lines of code.

UPDATE

I finished the skew, no errors there. just add a value to the whole of L1. However, my solution for random variation was to ask for a value (Ex, E)make a list 2x the size of L1 from randInt(-E,E,2dim(L1, then add that to L1. I believe there's a better solution out there.
Branching factor is the number of branches you add at each split.
ok. How would you suggest changing branching factor? Also, the program can only go to a iteration of 7-ish before it runs out of memory. this is due to me using five lists to store variables. having a higher branching factor means more branches, and instead of 2^7 endpoints, i'd have 3^7 endpoints.
If you want a variable branching factor, you need some method of encoding for each entry how many children you have and where they start. I like using complex numbers to encode this information. If you only want a fixed branching factor it's a simple formula based on your own position in the list.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement