# MEASUREMENTS from BEST FIT ARC . . .

2021-06-01-114853

All --

I would like to add a BEST FIT ARC TOOL to a project that I am working on.

In this application, the USER would create the BEST FIT ARC using 4 points.

In the SCREEN CAPTURE below, the BEST FIT ARC (BFA1) follows the CIRCLE.

For this project, the IMAGE-PRO CODE needs to create a NEW ARC (BFA2) that has

BFA2 CENTER = BFA1 CENTER

and

BFA2 RADIUS = BFA1 RADIUS - OFFSET

After doing an ADD ALL in the AVAILABLE MEASUREMENTS, BFA1 generates the following measurements.

The TIF IMAGE with BFA1 overlaid on the IMAGE is attached as

2021-06-01-114125.tif

When I record a MACRO and create a BEST FIT ARC, the code below is generated.

Public Function NewMacro3() As SimpleScript NewMacro3 = New SimpleScript Dim doc1, meas1 With Application.DocumentCommands.Active(NewMacro3) .Run(doc1) End With With Measure.MeasurementsCommands.Options(NewMacro3) .NMaxPointsArcs = 4 .Run(doc1) End With With Measure.MeasurementsCommands.Add(NewMacro3) .MeasurementType = McMeasurements.enumMMSTypes.mmtsBestFitArc .Points = New System.Collections.Generic.List(Of System.Drawing.PointF) .Points.Add(New System.Drawing.PointF(89.73759F,251.2154F)) .Points.Add(New System.Drawing.PointF(117.1162F,298.7089F)) .Points.Add(New System.Drawing.PointF(333.9099F,265.7428F)) .Points.Add(New System.Drawing.PointF(345.6436F,217.6906F)) .FeatureName = "BFA2" .SnapFeature = False .Run(doc1, meas1) End With End Function

Knowing the BFA1 CENTER, I can find 4 points that are OFFSET from the original BFA1 POINTS along lines from the POINTS to the CENTER. This is a bit of a headache but I know it can be done and then these points can be used to create BFA2.

Is there a better way to achieve a BFA2 that is CONCENTRIC with BFA1 but with a RADIUS that is reduced by an OFFSET?

Thanks.

-- Matt

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

0

## Answers

So, you want to draw a new arc with the same center, start and end angle, but different radius, right?

In that case you should use Arc Center X/Y, Arc Angle, Arc Radius, Start X/Y (or End X/Y) measurements of the original arc and calculate coordinates of arc points with the new radius for the given angle range. You can calculate coordinates of 3 points of the arc (Start, Middle, End) and create the new Arc (mmtsBestFitArc) or you can draw a Polyline (mmtsPolygonalLine) using more points of arc coordinates.

Yuri

Yuri --

There is no special function that would create an arc with modified radius, you should do all the calculations yourself based on the parameters I mentioned in the previous post.

Yuri

26

MyData.SubFeature(MyI).FeatureType

26

MyData.SubFeature(MyI).FeatureType

26

MyData.SubFeature(MyI).FeatureType

26

You have to use Start X/Y and End X/Y coordinates to calculate start and end Angle of the arc.

The easiest way to calculate the angle is by using atan2 function:

where x and y are Start X/Y or End X/Y and cx/cy are center coordinates.

Note that all Math functions handle angles in radians.

Here is the page with detailed explanation:

https://stackoverflow.com/questions/46387747/find-angle-of-point-on-circle

Let me know if it works for you.

Yuri

Start X/Y and End X/Y are the measurements of the arc:

you can get them the same way as Arc Center X/Y.

Yuri

Here is the post that explains how to get point coordinates of any feature: https://forums.mediacy.com/discussion/comment/543/

`Public Sub PrintOutlineCoordinates Dim im As McImage=ThisApplication.ActiveImage If im Is Nothing Then Exit Sub'no image Dim md As McMMData=im.MeasurementsData ThisApplication.Output.Show For Each sf As McMMSubFeature In md.SubFeatures Dim s As String=sf.Name Dim points() As SINGLEPOINT=Nothing sf.GetFeatures.GetFeaturePoints(sf.FeatureIndex,points) For Each p As SINGLEPOINT In points s+=" {" & p.x.ToString("F2") & "," & p.y.ToString("F2") & "}" Next ThisApplication.Output.PrintMessage(s) Next End Sub`

You can use it for an Arc as well.

Yuri