Point on arc with a given distance

Discussion in 'AutoCAD' started by mgrigoriev, May 19, 2004.

  1. mgrigoriev

    mgrigoriev Guest

    Is there a way in VB to put a point on an arc that will be a given distance away from its startpoint? I know I could use vlax-curve-getPointAtDist. Unfortunately, I can't. So, I am looking for a VB/math way to do it.
     
    mgrigoriev, May 19, 2004
    #1
  2. mgrigoriev

    wivory Guest

    I never deal with arcs so someone might have a better solution, but I thought I'd give this a crack.

    What about creating a line that starts at the startpoint and proceeds in any direction for the desired distance. Then use the IntersectWith to determine if the endpoint of the line lies on the arc. Unless you're really lucky it probably won't to start with, so then rotate the line (say 90 degrees) and repeat the IntersectWith test.

    If you're endpoint doesn't lie on the arc, but you do start getting some intersects along the line, then you can start doing like a binary search where you rotate the line back and forth whilst halving the angle of rotation until eventually your endpoint lands on the arc.

    If on the other hand you rotate all the way through 360 degrees without intersecting the arc then you've probably jumped over it, so try again with rotation steps of half the size (ie 45 degrees). If you get all the way around again then halve it again and so on. Eventually when you start getting some hits you can proceed with the binary search.

    Hope this helps.

    Regards

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, May 20, 2004
    #2
  3. mgrigoriev

    Jürg Menzi Guest

    Hi

    I'm sure there are more elegant solutions, but this code can give you an idea:

    '-----
    Function ArcPointAtDist(ArcObj As AcadArc, DstVal As Double) As Variant

    Dim ArcRad As Double
    Dim TmpAng As Double

    With ArcObj
    ArcRad = .Radius
    TmpAng = .StartAngle + (DstVal / ArcRad)
    ArcPointAtDist = ThisDrawing.Utility.PolarPoint(.Center, TmpAng, ArcRad)
    End With

    End Function
    '-----

    Cheers
     
    Jürg Menzi, May 20, 2004
    #3
  4. ...if the endpoint of the line lies on the arc.
    Wayne, you've just created a circle ;-) An IntersectWith of a circle
    (centered on the arc startpoint, and with radius equal to the desired
    distance) and the arc will give a point that's a given straight-line
    distance from the startpoint, and on the arc. If you don't get an
    intersection, then either the included angle or the radius of the arc is too
    small to have a point that far away.

    James
     
    James Belshan, May 20, 2004
    #4
  5. mgrigoriev

    mgrigoriev Guest

    Jürg,
    Thanks! That's exactly what I needed.
     
    mgrigoriev, May 20, 2004
    #5
  6. mgrigoriev

    wivory Guest

    Yes James I have gone full circle, but my solution was making discrete jumps (ie 90 degrees) so I may have stepped over a perfectly valid arc that was sitting at the 45-degree mark.

    Anyhow, it looks like Jürg has come up with the "proper" solution, but it was an interesting diversion.

    Regards

    Wayne
     
    wivory, May 21, 2004
    #6
  7. mgrigoriev

    Jürg Menzi Guest

    Glad to help you...

    Cheers
     
    Jürg Menzi, May 21, 2004
    #7
  8. this code do that !

    Public Function pointOnArc(pCentro As Variant, radio As Single, angBaseGrados As Single, distancia As Single, sentido As String, deltaAngGrados As Single, newAngleGrados As Single) As Variant
    'calcula un punto sobre un arco en base a un centro de arco, radio de arco, el angulo
    'inicial de grados y la distancia que se desea recorrer de arco
    'sentido= cw es en el sentido de las manecillas del reloj
    ' = ccw contrario a las manecillas del reloj
    Dim angRad As Single
    Dim longCircle As Single
    Dim p() As Double
    Dim Pi As Double

    Pi = 4 * Atn(1)
    ReDim p(2)
    longCircle = 2 * Pi * radio
    deltaAngGrados = (distancia * 360) / longCircle
    sentido = Trim(LCase(sentido))
    If sentido = "cw" Then
    newAngleGrados = angBaseGrados - deltaAngGrados
    Else
    newAngleGrados = angBaseGrados + deltaAngGrados
    End If
    angRad = gradosARadianes(CDbl(newAngleGrados)) 'CDbl convierte el single a double

    p(0) = radio * Cos(angRad) + pCentro(0)
    p(1) = radio * Sin(angRad) + pCentro(1)
    p(2) = 0
    pointOnArc = p
    End Function
     
    mauricioAlvarez, May 25, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.