Summary

Branched structures

Demo-file: Demo7.pov

Targeted random coils with defined subpositions are ideal to build up branched structures. I will demonstrate this ability with the following images. They show two examples of simply branched structures and one example for a branching pattern of second order.

Branched structure Branched structure Branched structure

In general these branching patterns are formed by first creating the main branch including the respective subpositions. These subpositions then become the starting points for the first order branches, which are created by a respective loop. The definition of the end positions of these branches is crucial for the overall geometry of the structure. Branches of higher order then have to be created by loops nested within this first order loop and are again initiated at subpositions from the first order (or later higher order) branches.
Below the code for the last image is given. The macros used for this image (which have already been introduced in a similar form) and the code for the other images is available in the respective demo-files.

//Initialization of pseudo-random streams.
#local chance1 = seed (13);
#local chance2 = seed (15);
#local chance3 = seed (23);

//The main branch

//First the parameters for the main branch are defined.
#declare NumberMain = 12;
#declare PositionsMain = array[NumberMain];
#declare StartMain = <0, 0, 0>;
#declare EndMain = <0, 12, 0>;
#declare VectorMain = EndMain - StartMain;
#declare RadiusMain = 0.01;
#declare DivisionsMain = 2;
#declare VarianceMain = 0.3;

//Then the array for this main branch is defined...
Sweep_Regular (StartMain, EndMain, NumberMain, VarianceMain, PositionsMain)

//...and the postions from this array are used to draw a Sphere_Sweep.
DrawSphereSweepVarRadius (PositionsMain, 0.18, 0.01, NumberMain)

//Subdivisions for the main branch.
#declare FinalNumber = (NumberMain - 2) + (NumberMain - 3) * DivisionsMain;
//Final number of old points combined with the new subpoints.

#declare SubpositionsMain = array[FinalNumber];
//Initialization of the array for the Subpoints.

Subdivisions (PositionsMain, NumberMain-2, DivisionsMain, RadiusMain, SubpositionsMain)

//First order branches.

//First some parameters for the small branches are defined...
#declare Angle1 = 0;
#declare Variance1 = VarianceMain*0.6;

//then a loop is started defining branches for all but the outermost subdivisions of the main branch.
#declare ticker1 = 1;
#while (ticker1 < dimension_size(SubpositionsMain, 1)-3)

//Now some more parameters for the first order branches.
#declare Number1 = NumberMain - div(ticker1+10,(DivisionsMain+1)+2);
#declare Positions1 = array[Number1];

//The start position for the branches are defined by the subdivisions of the main branch.
#declare Start1 = SubpositionsMain[ticker1];

//The end positions of the branches are defined by the following lines.

#declare End1 = Start1 + <0.5*vlength(EndMain-Start1) + 0.2 *(rand(chance1) - 0.5), vlength(EndMain-StartMain)/24 + vlength(EndMain-Start1)/3, 0>;
#declare End1 = vaxis_rotate (End1, EndMain-StartMain, Angle1 + 5 *(rand(chance3) - 0.5));

#declare Angle1 = Angle1 + 137.5;
Sweep_Regular (Start1, End1, Number1, Variance1, Positions1) //Here the arrays for the branches are defined...

DrawSphereSweepVarRadiusb (Positions1, 0.12, 0.01, Number1) //...and the postions from these arrays are used to draw respective Sphere_Sweeps.

#declare Vector1 = End1-Start1;

#if (Number1 >3)

//Subdivisions for the first order branches.

#declare Radius1 = 0.01;
#declare Divisions1 = 1;

#declare FinalNumber1 = (Number1 - 2) + (Number1 - 3) * Divisions1; //Final number of old points combined with the new subpoints.

#declare Subpositions1 = array[FinalNumber1];

Subdivisions (Positions1, Number1-2, Divisions1, Radius1, Subpositions1)

//Second order branches.

//First some parameters are defined...
#declare Angle2 = 0;
#declare Number2 = 5;
#declare Positions2 = array[Number2];
#declare Variance2 = 1;

//Then a loop is started defining branches for all but the outermost subdivisions of the main branch.
#declare ticker2 = 1;
#while (ticker2 < dimension_size(Subpositions1, 1)-1)

//The start position for the branches are defined.

#declare Start2 = Subpositions1[ticker2];

//The end positions of the branches are defined.

#declare End2 = 0.3 * (End1 - Start2);
#declare End2 = vrotate (End2, <55 + 5 *(rand(chance3) - 0.5), 0, 0>);
#declare End2 = vaxis_rotate (End2, End1-Start2, Angle2 + 5 *(rand(chance3) - 0.5));
#declare End2 = End2 + Start2;

//Two subsequent lateral branches are rotated by the "golden angle".
#declare Angle2 = Angle2 + 137.5;

//Macro defining the positions for a given second order branch.
Sweep_Regular (Start2, End2, Number2, Variance2/10, Positions2)

//Macro drawing a given second order branch.
DrawSphereSweepVarRadius (Positions2, 0.08, 0.007, Number2)

#declare ticker2 = ticker2 + 1;
#end
#else
#end
#declare ticker1 = ticker1 + 1;
#end

Summary