Esempio n. 1
0
        // returns false if angle>180
        bool CalculateMiddlePoint()
        {
            Vector2 v21    = corner2.Point - corner1.Point;
            float   angle1 = VectorUtil.UnsignedAngleRad(v21, corner1.DirMain);  // expected Accute
            float   angle2 = VectorUtil.UnsignedAngleRad(-v21, corner2.DirMain); // expected Accute
            float   c      = Mathf.PI * .5f - Epsilon;

            if (angle1 >= c || angle2 >= c)
            {
                Log.Debug("Roundabout angle >= 180");
                return(false);
            }

            var b2 = BezierUtil.Bezier2ByDir(
                corner1.Point, corner1.DirMain,
                corner2.Point, corner2.DirMain);

            MiddlePoint = b2.Travel2(b2.ArcLength() * .5f, out MDir2);
            MDir1       = -MDir2;
            return(true);
        }