Wed, 01/08/2025 - 07:13
Forums:
I have two parallel edges, both of type gp_Lin. When I call line1.Distance(line2), the result is not ideal. I found that in the gp_Lin::Distance(gp_Lin) function, there is a check to determine if the two lines are parallel. If they are parallel, it calls gp_Lin::Distance(gp_Pnt). Now, I have realized that the function checks for parallelism using a resolution of gp::Resolution == DBL_MIN, which leads to inaccurate results. I wonder if using Precision::Confusion == 1.0E-7 would be better??Please check the image below.
Actually,i can get the correct result by ”dist = cur1.Line().Distance(cur2.Line().Location());”
Attachments:
Wed, 01/08/2025 - 13:28
Hello. Could you share the difference in text from?
Confusion can't be used in current context. The recommended is https://github.com/Open-Cascade-SAS/OCCT/blob/3d6c21124ad052d1efa7fd6cb8...
But checking for FLOAT_MIN is a normal solution. I would expect the issue with direct calculation. Need to analyse differences, could you share more samples in text? With values.
Best regards, Dmitrii.
Thu, 01/09/2025 - 09:23
Thanks Dmitrii.
I used to directly use the interface name 'Distance' when I saw it. Now, after looking at the underlying implementation principle, I realize that the tolerance for parallelism (Tol) is crucial to the result. What do you think about Precision::Angular()? DBL_MIN or FLT_MIN makes sense, but it feels a bit too strict. I checked the underlying implementation of GeomAPI_ExtremaCurveCurve. For two lines (Line), the underlying parallelism check condition is one where aD1.IsParallel(aD2, Precision::Angular()); for parallel lines, their calculation method is the same.
Overall, it's my fault. I want to compute the distance between parallel edges, so I should use my own Tol to check parallelism, but then manually call gp_Lin::Distance(gp_Pnt). Thanks.
Regards,
lws-sys.
Thu, 01/09/2025 - 13:07
Hello, my apologies for not clear response.
It is not your fault, the API is limited. I will extend it with precision. And I need to check issue with non parallel calculations in case of almost parallel. But I just want to have samples(values) to validate.
Best regards, Dmitrii.
Fri, 01/10/2025 - 06:36
Thanks Dmitrii.
i write a test and check the result in image.
The code performs the following operations:
it filters potential parallel edges with a tolerance of 1 degree,records parallel edge pairs with an angular error less than 1 degree and a distance greater than 0.0001 (i.e., not coaxial),and simultaneously records their real angles.Finally, it checks the distribution of these real angles within a certain range.And show the distance of two parallel edges,calculated by different way.
Sorry,I can't upload the STEP model data, but you can easily input them in bulk and perform repeated testing.
Regards,
lws-sys.