Issue #6613 - [Bug] Draft Snap Near is inaccurate when snapping to curves

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
NewJoker
Veteran
Posts: 3021
Joined: Sun Oct 11, 2020 7:49 pm

Issue #6613 - [Bug] Draft Snap Near is inaccurate when snapping to curves

Post by NewJoker »

Hi,

I'm testing the Draft Snap Near option. For this purpose I created a circle and I tried to snap a line at an arbitrary angle to it. The Snap Near symbol appeared and it seems that the snap worked:

snap near 1.png
snap near 1.png (9.08 KiB) Viewed 2038 times

But when I zoom in closely, I can see some inaccuracy - the line ends not exactly on the circle but somewhere before or after it:

snap near 2.png
snap near 2.png (6.53 KiB) Viewed 2038 times

I thought that it's just a display issue since the circle is likely shown in the form of straight line segments (like in the Sketcher). But when I select that line and dimension it, the value is slightly different than the radius of the circle (the line starts from the center of the circle, I used Snap Center to ensure that). For example, it can be 37,97 mm or 37,99 mm instead of 38 mm.

All the other snaps were disabled so it can't be a problem of e.g. Snap Grid taking precedence over Snap Near.

Is that a bug or just my misunderstanding of how it's supposed to work ?
Last edited by Kunda1 on Thu Jun 02, 2022 2:39 pm, edited 1 time in total.
Reason: Added GH ticket number to thread title
User avatar
Roy_043
Veteran
Posts: 8456
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft Snap Near accuracy

Post by Roy_043 »

Confirmed. The near snap indeed snaps to the polygonal representation of the circle. There is even a slight 'magnetic' effect if you snap on a corner of the polygon. IMO this is a bug.

Note that in your zoomed-in image the line crosses the polygonal representation, I do not get that.
User avatar
NewJoker
Veteran
Posts: 3021
Joined: Sun Oct 11, 2020 7:49 pm

Re: Draft Snap Near accuracy

Post by NewJoker »

Roy_043 wrote: Sat Mar 19, 2022 7:51 pm Confirmed. The near snap indeed snaps to the polygonal representation of the circle. There is even a slight 'magnetic' effect if you snap on a corner of the polygon. IMO this is a bug.

Note that in your zoomed-in image the line crosses the polygonal representation, I do not get that.
Thank you for confirming this.

Could moderators move this to the Draft subforum as a potential bug report ? Or should I create a new topic there ?
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Draft Snap Near accuracy

Post by chrisb »

Moved to Draft forum.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Draft Snap Near accuracy

Post by thomas-neemann »

NewJoker wrote: Sat Mar 19, 2022 6:52 pm ... For this purpose I created a circle and I tried to snap a line at an arbitrary angle to it. ...
confirmed. here's a workaround if you want it to be precise


https://www.youtube.com/watch?v=xvPkNq7g7a0


phpBB [video]
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
NewJoker
Veteran
Posts: 3021
Joined: Sun Oct 11, 2020 7:49 pm

Re: Draft Snap Near accuracy

Post by NewJoker »

thomas-neemann wrote: Sat Mar 19, 2022 9:01 pm confirmed. here's a workaround if you want it to be precise


https://www.youtube.com/watch?v=xvPkNq7g7a0
Another workaround (likely the easiest one) would be to draw the line longer than it should be (so that it extends outside the circle) and then use the Draft Trimex tool on it, picking the circle as an object for the intersection. The result still seems inaccurate but that's apparently just a display issue - dimensioning shows correct value in this case.

Meanwhile, I created a bug report for that on GitHub: https://github.com/FreeCAD/FreeCAD/issues/6613
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Draft Snap Near accuracy

Post by thomas-neemann »

NewJoker wrote: Sat Mar 19, 2022 10:23 pm ...
Another workaround (likely the easiest one) would be to draw the line longer than it should be ....
yes, it works (very accurate for me too) but no white dot is displayed when snapping in. when i draw a second line, the white dot is shown when snapping (snap intersection)
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Issue #6613 - [Bug] Draft Snap Near is inaccurate when snapping to curves

Post by Kunda1 »

Updated thread title with GH issue.

Any takers for issue #6613 ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Issue #6613 - [Bug] Draft Snap Near is inaccurate when snapping to curves

Post by yorik »

This is IMHO not exactly a bug - obtaining cartesian coordinates from a point on a circle inherently depends on how much precision you give to PI, which is then always imprecise, as there is no absolute value for PI. Raising the precision value in the Draft preferences makes this imprecision smaller.

There is also the fact that on screen, curves are represented faceted (OpenGL can only represent straight lines), so you might see on screen something that is not properly intersected, while in "reality", internally, it is. Raising the Deviation value of the curved objects makes the faceting smoother.

So I think this is basically unsolvable?
User avatar
Roy_043
Veteran
Posts: 8456
Joined: Thu Dec 27, 2018 12:28 pm

Re: Issue #6613 - [Bug] Draft Snap Near is inaccurate when snapping to curves

Post by Roy_043 »

I think you have misunderstood. Currently Near snap snaps to the inaccurate representation of a circle in the 3D view. No attempt is made to project the point on the actual geometry. Doing that should be possible I think, but I do not know how hard that would be. Anyway, not something that should squeezed in for V0.20 IMO.
Post Reply