0

我正在重写一个树分形代码来绘制 L-Systems,只有 1 条长线用于 3d 螺旋图、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°: 非 90' 角问题

4

0 回答 0