Author Topic: Converting Arc to CircularArc3d  (Read 8465 times)

0 Members and 1 Guest are viewing this topic.

sinc

  • Guest
Re: Converting Arc to CircularArc3d
« Reply #15 on: December 01, 2007, 10:30:58 AM »
I took the easier way :-)

First, get start and end parameters of an Arc:
Code: [Select]
Dim p0 As Double = arc.StartParam
Dim p1 As Double = arc.EndParam

Calculating a parameter for midpoint uses either:
Code: [Select]
Dim pM As Double = (p1 - p0) / 2
or:
Code: [Select]
Dim pM As Double = (p1 + p0) / 2

Which one to use depends on Arc geometry... but I didn't have time to find out the relation, must be some basic Arc property (I guess it's about angles). I'll check it out and post tomorrow.


Since arcs are alwasy defined in the counter-clockwise direction, isn't it simply:

Code: [Select]
if (p0 < p1)
  pM = (p1 - p0) / 2
else
  pM = (p0 + p1) / 2

MaksimS

  • Guest
Re: Converting Arc to CircularArc3d
« Reply #16 on: December 01, 2007, 10:53:06 AM »
This won't work, since If function always evaluates to True. Try for yourself. Exception being thrown: Autodesk.AutoCAD.Runtime.Exception: eInvalidInput

sinc

  • Guest
Re: Converting Arc to CircularArc3d
« Reply #17 on: December 01, 2007, 12:16:25 PM »
Oh, sorry...

With parameters on arcs, isn't the midpoint ALWAYS:

midParam = (startParam + endParam) / 2

When would it ever be anything else?

That relationship isn't true for polylines, but it should always be true for arcs and lines...  At least, that's what it's looking like to me.

I just realized that the parameter for arcs is the angle (in radians) from the X axis, and that the following are true:

 0 <= StartParam < 2*pi
StartParam < EndParam < StartParam + 2*pi

Glenn R

  • Guest
Re: Converting Arc to CircularArc3d
« Reply #18 on: December 01, 2007, 01:31:56 PM »
That's some very interesting observations sinc.

MaksimS

  • Guest
Re: Converting Arc to CircularArc3d
« Reply #19 on: December 03, 2007, 07:27:48 AM »
Sinc, really sound observation. I'll give it a try, on both lines/arc and polylines (with arcs). I have a helper function that converts any arc to CircularArc, and it's supposed to handle arcs coming from either entity. So, basically, orientation is an issue here.

Regards,
Maksim Sestic