Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

project point to body

Evan_ReeseEvan_Reese Member Posts: 1,000 PRO
I'm working on a feature that will pull points to a body in various ways: closest point, and projected along a direction. I'm using evDistance for the closest point and evRaycast for the projection. It seems like evRaycast is about 10x slower. What can I do to optimize? Should I even be using evRaycast? Performance matters because I'll be iterating over a large number of points.
Evan Reese / Principal and Industrial Designer with Ovyl
Website: ovyl.io
Instagram: @evan.reese.designs

Answers

  • Alex_KempenAlex_Kempen Member Posts: 195 EDU
    evRaycast set to closest is probably the most straightforward way to project a point onto a face along an arbitrary direction. If you know some stuff about the face you're projecting onto, however, evDistance can probably provide information much more quickly. For example, defining your line as a line object and then using evDistance with a query for the face and the line object should return a result which should include the parameter space coordinates for the point where the line intersects the face. It can also return the point of intersection represented as the length of the line along the specified direction, which can be pretty handy. Let me know if you would like me to explain what evDistance returns in more detail, as the nested maps and arrays can be quite confusing.
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,171 ✭✭✭✭✭
    edited September 24
    evRaycast() provides a guarantee that the intersection found is the closest, which we haven't for evDistance(). And after all its not as slow. My project feauture can make a hundreds of evRaycast() calls per one feature call and it takes seconds
  • Evan_ReeseEvan_Reese Member Posts: 1,000 PRO
    Thanks, guys. All of that makes sense. I think raycast has some advantages for what I'm doing, so I'll stick with it for now.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
    Instagram: @evan.reese.designs
Sign In or Register to comment.