Exemplo n.º 1
0
        private float CalculateRadius(Vector3 start, Vector3 middle, Vector3 end, Vector3 control)
        {
            float radius;

            float tangent1 = VectorUtils.LengthXZ(control - start);
            float tangent2 = VectorUtils.LengthXZ(control - end);

            if (Mathf.Abs(tangent1 - tangent2) <= Mathf.Abs(tangent1 * .0001f))
            {
                radius = tangent1;
            }
            else
            {
                float area        = Triangle3.Area(start, middle, end);
                float sideLength1 = Vector3.Distance(start, middle);
                float sideLength2 = Vector3.Distance(middle, end);
                float sideLength3 = Vector3.Distance(end, start);

                radius = 1 / (4 * area / (sideLength1 * sideLength2 * sideLength3));
            }

            return(radius);
        }