70002545 I want to calculate the smallest circle that includes all the points of a polyline

Article 70002545
Type Wish
Product Engine
Version 11
Date Added 7/20/2024 12:00:00 AM
Fixed 11.2.2.0 (7/20/2024 12:00:00 AM)
Submitted by liufutao

Summary

I want to calculate the smallest circle that includes all the points of a polyline

Solution

In version 11.2.2 we added the following method to the vdCurve object

summary> Calculates and returns the center and the redius of the smallest circle that includes all the points of the polyline.
remarks>The polyline must be 2D.
param name="Center">The return center of the calculated circle.
param name="radius">The return radius of the calculated circle.
returns>True if the operation was succesfull.
public bool FindSmallestEnclosingCircle (out gPoint Center, out double radius)

c# code example

                gPoint pt = null;
                vdFigure fig = null;
                doc.Prompt("Select Curve:");
                StatusCode scode = doc.ActionUtility.getUserEntity(out fig, out pt);
                doc.Prompt(null);
                vdCurve curve = fig as vdCurve;
                if (curve != null)
                {
                    gPoint center;
                    double radius;
                    bool succ = curve.FindSmallestEnclosingCircle(out center, out radius);
                    if (succ)
                    {
                        vdCircle circle = new vdCircle(doc, center, radius);
                        circle.PenColor.ColorIndex = 0;
                        circle.Transformby(curve.ECSMatrix);
                        doc.Model.Entities.AddItem(circle);
                        doc.Redraw(true);
                    }
                }

Send comments on this topic.