Пример #1
0
        public static Circle2D CreateFromPoints(Vector2[] points)
        {
            Circle2D circle = new Circle2D();
            AABB2D box = AABB2D.CreateFromPoints(points);
            circle.Pos = box.Pos;
            float maxDist = float.MinValue;

            for (int i = 0; i < points.Length; i++)
            {
                if ((points[i] - circle.Pos).LengthSquared() > maxDist)
                {
                    maxDist = (points[i] - circle.Pos).LengthSquared();
                }
            }

            maxDist = (float)Math.Sqrt(maxDist);

            circle.Radius = maxDist;

            return circle;
        }
Пример #2
0
        public static Circle2D CreateFromPoints(Vector2[] points)
        {
            Circle2D circle = new Circle2D();
            AABB2D   box    = AABB2D.CreateFromPoints(points);

            circle.Pos = box.Pos;
            float maxDist = float.MinValue;

            for (int i = 0; i < points.Length; i++)
            {
                if ((points[i] - circle.Pos).LengthSquared() > maxDist)
                {
                    maxDist = (points[i] - circle.Pos).LengthSquared();
                }
            }

            maxDist = (float)Math.Sqrt(maxDist);

            circle.Radius = maxDist;

            return(circle);
        }