.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mid point on arc

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
4765 Views, 3 Replies

Mid point on arc

How do find the midpoint on a arc?

3 REPLIES 3
Message 2 of 4
chiefbraincloud
in reply to: Anonymous

You can use either the GetPointAtParameter, or the GetPointAtDistance functions.  The parameter for an arc is the angle around the circle (from 0) at which you want the Point, but other curve objects (like polylines for instance), would be different.

 

Dim midbyParam As Point3d = _arc.GetPointAtParameter(_arc.StartAngle + (_arc.TotalAngle / 2))

Dim midbyDist As Point3d = _arc.GetPointAtDist(_arc.Length / 2)

Dave O.                                                                  Sig-Logos32.png
Message 3 of 4
Anonymous
in reply to: chiefbraincloud

Thanks cheifBrainCloud

 

That was dead on.

 

Just to know the midbyParam would get off a little on large arcs. By large arcs I mean around 160' between start and end point, but the block inserted on the arc was always dead on with the midbyDist

Message 4 of 4
Anonymous
in reply to: Anonymous

That code really isn't a good way to get the midpoint of an arc

because it relies on assumptions about what the parameter of

the curve represents.

 

It's generally bad design to write code that relies on assumptions

about what exactly the parameter of a Curve represents, mainly

because that code will not work generically on any type of Curve.

 

So, in cases where you are dealing with different types of Curves,

that type of coding would force you to test each Curve type, and

branch to different code to deal with each.

 

While you may want to midpoint of an arc now, there is no

justifiable reason to write an arc-specific method to get the

midpoint,when you can just as easily write a generic solution

that returns the midpoint of any non-closed Curve that has a

finite length (e.g., no rays/xlines):

 

public static Class CurveExtensionMethods
{

// excludes error checking for closed & infinite-length curves:

 

   public static Point3d GetMidpoint( this Curve curve )
   {

      double d1 = curve.GetDistanceAtParameter( curve.StartParam );
      double d2 = curve.GetDistanceAtParameter( curve.EndParam );
      return curve.GetPointAtDist( d1 + ( ( d2 - d1 ) / 2.0 ) );
   }
}


 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost