Tolerance for Intersection?

Discussion in 'AutoCAD' started by mgrigoriev, Aug 10, 2004.

  1. mgrigoriev

    mgrigoriev Guest

    Hi,
    In WCS with Ortho on I draw two perpendicular lines. The end point of the first line is the startpoint of the second. Now, I move one of the lines away from the other 0.05 units. On the drawing you can clearly see that the lines are not intersecting any more. Although, when I use IntersectWith method it still shows as if lines are intersecting. The magic number os 0.07. If the distance between the lines is less than 0.07 they will be shown as intersecting. Is there a variable that distinguishes a tolerance for intersecting objects?

    Here's the code I use to see if lines intersect:

    Sub aa()
    Dim returnObj1 As AcadObject, returnObj2 As AcadObject
    Dim basePnt As Variant
    ThisDrawing.Utility.GetEntity returnObj1, basePnt, "Select an object"
    ThisDrawing.Utility.GetEntity returnObj2, basePnt, "Select an object"
    intPoints = returnObj1.IntersectWith(returnObj2, acExtendNone)
    MsgBox UBound(intPoints)
    End Sub

    Thanks,
    Mike
     
    mgrigoriev, Aug 10, 2004
    #1
  2. Are those lines at large coordinate locations? You sample works fine near
    0,0.

    --
    R. Robert Bell


    Hi,
    In WCS with Ortho on I draw two perpendicular lines. The end point of the
    first line is the startpoint of the second. Now, I move one of the lines
    away from the other 0.05 units. On the drawing you can clearly see that the
    lines are not intersecting any more. Although, when I use IntersectWith
    method it still shows as if lines are intersecting. The magic number os
    0.07. If the distance between the lines is less than 0.07 they will be shown
    as intersecting. Is there a variable that distinguishes a tolerance for
    intersecting objects?

    Here's the code I use to see if lines intersect:

    Sub aa()
    Dim returnObj1 As AcadObject, returnObj2 As AcadObject
    Dim basePnt As Variant
    ThisDrawing.Utility.GetEntity returnObj1, basePnt, "Select an object"
    ThisDrawing.Utility.GetEntity returnObj2, basePnt, "Select an object"
    intPoints = returnObj1.IntersectWith(returnObj2, acExtendNone)
    MsgBox UBound(intPoints)
    End Sub

    Thanks,
    Mike
     
    R. Robert Bell, Aug 10, 2004
    #2
  3. mgrigoriev

    mgrigoriev Guest

    Yes, the coordinates are pretty large, like 6 digits.
     
    mgrigoriev, Aug 10, 2004
    #3
  4. I'm not surprised. Remember that AutoCAD is accurate to only 14 significant
    digits.

    You could temporarily change the UCS origin to one of your pick points
    before attempting to locate the intersection.
     
    R. Robert Bell, Aug 10, 2004
    #4
  5. mgrigoriev

    mgrigoriev Guest

    Thanks, I'll try that.
     
    mgrigoriev, Aug 10, 2004
    #5
  6. mgrigoriev

    mgrigoriev Guest

    Robert, the intersection still returns the coordinates in WCS. That means that the problem cannot be solved by changing the UCS Origin.
     
    mgrigoriev, Aug 10, 2004
    #6
  7. Yes, it appears that method uses WCS to determine intersection, so the usual
    workaround (for hatches and so on) doesn't help.

    Sorry.

    Another approach you could take when dealing with large coords is to copy
    the objects to near WCS 0,0,0, determine intersection, then translate coords
    back to original location. <blech>

    --
    R. Robert Bell


    Robert, the intersection still returns the coordinates in WCS. That means
    that the problem cannot be solved by changing the UCS Origin.
     
    R. Robert Bell, Aug 10, 2004
    #7
  8. The problem you are seeing is fundamental to any floating
    point coordinate system. Look at the coordinates of the
    lines involved, and count the number of significant places
    to the left of the decimal point, subtract from 8, and the
    result is the number of usable digits to the right of the
    decimal point.

    Translating the geometry closer to the origin might seem
    to help solve the computation problem but in fact, when
    you translate the objects back to the original location they
    may not be in the exact same location, and/or the calculated
    intersection point that you must also translate in that case,
    may not be accurate.



    first line is the startpoint of the second. Now, I move one of the lines
    away from the other 0.05 units. On the drawing you can clearly see that the
    lines are not intersecting any more. Although, when I use IntersectWith
    method it still shows as if lines are intersecting. The magic number os
    0.07. If the distance between the lines is less than 0.07 they will be shown
    as intersecting. Is there a variable that distinguishes a tolerance for
    intersecting objects?
     
    Tony Tanzillo, Aug 10, 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.