I am rewriting a tree fractal code to draw L-Systems with only 1 long line for 3d spirographs, 3d architecture etc.
I have rotation errors: 90° angle Sin/Cos makes some angles with 45° and 135° instead of 90° Why?
//A recursive function used to draw the fractal tree
function drawTree( x1 : float, y1 : float, z1 : float, y3 : float, angle : float, angle2 : float, depth : int){
if (depth != 0){
var x2 : float= x1 + (Mathf.Cos(angle * deg_to_rad) );
var z2 : float= z1 + (Mathf.Cos(angle2 * deg_to_rad) );
var y2 : float= y1 + (Mathf.Sin(angle * deg_to_rad) );
var y4 : float= y3 + (Mathf.Sin(angle2 * deg_to_rad) );
var n1 : float = (y3+y1);
var n2 : float= (y4+y2);
if (depth > 1 ){drawLine2(x1, n1, z1, x2, n2, z2, depth);}
if(depth%2 == 0)
drawTree(x2, y2, z2, y4, rand_90_degrees_x4_function(depth) , 0 , depth - 1);
else
drawTree(x2, y2, z2, y4, 0 , rand_90_degrees_x4_function(depth+2) , depth - 1);
}
}
Why are some angles not 90° at beginning and end: