fCraft.Forester.RoundTree.ShapeFunc C# (CSharp) Method

ShapeFunc() protected method

protected ShapeFunc ( int y ) : float
y int
return float
            protected override float ShapeFunc( int y )
            {
                float twigs = base.ShapeFunc( y );
                if ( twigs >= 0 )
                    return twigs;

                if ( y < Height * ( .282 + .1 * Math.Sqrt( Args.Rand.NextDouble() ) ) ) {
                    return -1;
                }

                float radius = Height / 2f;
                float adj = Height / 2f - y;
                float dist;
                if ( adj == 0 ) {
                    dist = radius;
                } else if ( Math.Abs( adj ) >= radius ) {
                    dist = 0;
                } else {
                    dist = ( float )Math.Sqrt( radius * radius - adj * adj );
                }
                dist *= .618f;
                return dist;
            }
Forester.RoundTree