Fractal Tree Library with Bezier Curves

Fractal Tree Library with Bezier Curves

Description

#2D Fractal Tree Library# This Library Creates 2D Objects That Can Be Exported As Svg Objects This Does Not Produce A Valid Three Dimensional Object That Can Be Printed. ##Tl;Dr:## + `Trunk();` + F6 (Render) + Export As An Svg In Openscad: `File > Export > Export As Svg` ##Thanks## All Bezier Functions Based On The Excellent Work Of @Caterpillar [Justin Sdk](Https://Www.Thingiverse.Com/Justinsdk/About) Https://Openhome.Cc/Egossip/Openscad/Beziercurve.Html Thanks To Steveweber314 For His Fractal Tree Tutorials Https://Www.Thingiverse.Com/Steveweber314/About The Latest Version Of This Can Be Found At Github: Https://Github.Com/Txoof/Fractal_Tree ##Licenses## Releasted Under Gpl V3 - Share Alike Please See The Included License File For The Complete License Text ##Readme## This Library Uses Psuedo-Random Bezier Curves To Generate A 2D Vector Drawing Of A Tree. There Are *Many* Paramaters That Can Be Adjusted To Produce Different Trees. To Use This Within Another Openscad Design Try: Use </Path/To/This/File/Bezier_Tree.Scad> Trunk(); Here Are Three Examples All Grown From The Same "Seed" But With Tweaks To The Parameters To Produce Three Very Different Trees. To Produce A Tree Simliar To A Birch Tree (Thin, Tall, Quickly Diminishing, And Straight) Try The Following Settings: Trunk(Size = 900, Bend = 25, Seed = 40, Depth = 12, Widthbottom = 100, Widthtop = 90, Maxangle = 45, Minangle = 35, Branchprob = [40, 20, 10], Maxgrowth = .9, Mingrowth = .9, Decay = .85); To Produce A Tree Similar To A Gnarled Old Oak (Thick, Branching Horizontally, With A Bushy Crown) Try The Following Settings: Trunk(Size = 600, Bend = 150, Seed = 40, Widthbottom = 300, Widthtop = 280, Maxangle = 75, Minangle = 55, Branchprob = [20, 50], Maxgrowth = 1.0, Decay = .93, Depth = 6); A Reasonable Poppler (Tall, Stright, Fast Growing And Vertical) Can Be Prodced With These Settings: Trunk(Size = 1500, Bend = 100, Seed = 40, Widthbottom = 300, Widthtop = 280, Maxangle = 15, Minangle = 15, Branchprob = [10, 50], Maxgrowth = 1.0, Decay = .93, Depth = 6); To Produce A Tree Of A Particular Dimension Use: Resize([0, 0, 500], Auto = True) //Resize To A Height Of 500 Trunk(Size = 1500, Bend = 100, Seed = 40, Widthbottom = 300, Widthtop = 280, Maxangle = 15, Minangle = 15, Branchprob = [10, 50, 30], Maxgrowth = 1.0, Decay = .93, Depth = 6); ###Design Considerations### To Create More Bent Branches Increase The Bend/Size Ratio. Size = 500, Bend = 250 Will Make A Very Twisted Tree Setting Depth Above 9 Can Result In Very Long Excution Times As The Recursion Grows Exponentially With Depth ###Paramaters### Module Trunk() Paramaters: Denotes Parameter That Is Used Internally By Recursion And Is Not Intended To Be Used From The Inital Module Call (Suggested Values In Parentheses) Size [Real] Size Of First Segment (Linear From Origin) Seed [Real] Seed With Which To Generate A Psuedo-Random Tree Depth [Integer] Recusion Level (1 To 8) Widthbottom [Real] Maximum Width At Base Of Trunk Widthtop [Real] Maximum Width At Top Of First Trunk Segment Mingrowth [Real] Minimum Amount To Grow The New Branch (0.1 To 1.2) Maxgrowth [Real] Maximum Amount To Grow The New Branch (0.1 To 1.2) Decay [Real] Base Amount To Diminish Each Branch By (0.5 To 1.2) Minangle [Real] Minimum Angle To Rotate Each Branch (0 To 180) Maxangle [Real] Maximum Angle To Rotate Each Branch (0 To 180) Branchprob [Vector] % Chance Of One, Two Or Three Branches Occuring [%One, %Two] ([10, 40]) - %Three Is Calculated As The Remainder Of 100-%One-%Two. In This Case, %50. Step [Real] Step Size To Use When Generating Bezier Curves Values Approaching 0 Are Smoother, But Take Much Longer To Render (0.05) *Depthmax [Integer] Records Maximum Depth On First Call *Distance [Integer] Records Distance From "Trunk" - Can Be Used To Diminish Branches *Start [Vector] Records [X, Y, Z] Vector At Which To Start *First [Boolean] First Run Sets Persistent Variables For Recursion Growing The Branch Debug [Boolean] Turn On Debugging Including Control Points

Statistics

Likes

39

Downloads

0

Category

2D Art