RobotStudio event

Find intersection of wire with face

Options
I have a straight wire which intersects with a curved face, and I need to find the Vector3 position of the intersection.

I cannot use the Plane.Intersect method because the face is not a plane.

I cannot use the Part.IntersectRay method because this operates on the graphics rather than the true geometry, so errors occur due to graphical approximations.

Is there a method which will give the required result?

If not, I could step along the wire and use the Body.IsPointInside method at each position to detect the intersection, but this is likely to be slow. Is there a better way?

Thanks,

Kevin

Comments

  • Kevin
    Kevin ✭✭
    Options
    image

    The image shows a block with a curved top face 'face' and an intersecting wire. The block and wire are contained in separate parts which are located at the global origin.
    I need to find the intersection of the wire and face, so I step down the edge contained in the wire and test each point to discover whether it is inside the block. (I then step back up with smaller increments to get an accurate result). This is part of the method:[CODE]
    Double step = 0.001;      // increment for stepping down the wire
    Double testLength;        // distance along edge to test
    Vector3 point;            // position of intersection if 'true' is returned

    for (testLength = 0; testLength <= edge.Length; testLength += step)
    {
         point = edge.GetPointAtParameter(edge.GetParameterAtLength(testLength));
         if (face.Body.IsPointInside(point))
         {
              return true;
         }
    }
    return false;[/CODE]
    This works OK with the block in its original position, but if I move the block before creating the wire, the wire appears correctly located but no point is found inside the block.
    I have tried moving the wire Part to the same new location as the block before creating the wire, but the method still fails.

    What must I do to get the method to work with the block in any position?

    Is there a better method of finding the intersection? This method is not perfect because it will not work at the edge of a very thin block.

    Thanks,

    Kevin

  • Henrik Berlin
    Options
    Hi Kevin,
     

    As you have noticed, the documention for the IntersectRay method is incorrect. We log an error report about that.

     

    Not that I am an API expert, but have perhaps what you can do is to use the "IntersectRay" to get the correct intersection face and an approximate intersection point in the mesh. Use this data as input for the "NormalToSurface" method that will project the point onto the face.  Using the "Fine"-mesh will increase the accuracy of the output of IntersectRay.
    Henrik Berlin
    ABB
  • Kevin
    Kevin ✭✭
    Options
    Hi Henrik,

    Thanks for the suggestion. Can I set mesh to fine just for the block and the wire using the API, or must I set it globally in 'RS Options/Graphics/Performance/Rendering detail level'. I have had no luck searching API help.

    Regards,

    Kevin

  • Hi Kevin,

    You can set it to fine, re-import the part and set it back to the default. The setting is used only when importing geometry.

    regards,
    Johannes

    Johannes Weiman
    Software Engineer
    ABB Robotics