我正在重写一个树形分形码来绘制L-Systems,只有一条长线用于三维螺旋形图,3d架构等。
我有旋转误差:90°角Sin / Cos会使一些角度为45°和135°而不是90°为什么?
//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);
}
}
为什么某些角度在开始和结束时不是90°: