[Sketcher] snapping discussion

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Hologram
Posts: 201
Joined: Thu Nov 03, 2022 3:05 pm

Re: [Sketcher] snapping discussion

Post by Hologram »

I stand corrected then.
User avatar
adrianinsaval
Veteran
Posts: 5534
Joined: Thu Apr 05, 2018 5:15 pm

Re: [Sketcher] snapping discussion

Post by adrianinsaval »

chrisb wrote: Wed Feb 08, 2023 8:56 pm You seem to be pretty new here and I'm a bit surprised that you are calling Gene to order. He is for good reasons a moderator because he always stays calm and fair.
I won't question Gene's role as moderator as I feel he does a very good job, but moderators are people too so not without fault, IMO it's ok to call out someone's behavior even if they are a moderator
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: [Sketcher] snapping discussion

Post by GeneFC »

I won't argue any points about my behavior, but I will comment further on the "creeping elegance".

I believe that Paddle stated there was a fairly short deadline for the first pass.

I have seen a number of projects over the years get bogged down by continuous additions. (The addon suggestion above will not be the last one.)

Make a plan, execute, and get some output. The elegance can come later.

Gene
chrisb
Veteran
Posts: 53785
Joined: Tue Mar 17, 2015 9:14 am

Re: [Sketcher] snapping discussion

Post by chrisb »

adrianinsaval wrote: Wed Feb 08, 2023 9:40 pm moderators are people too so not without fault, IMO it's ok to call out someone's behavior even if they are a moderator
You are of course very right here with this very general statement. That's why I didn't say that it is not allowed to criticize a moderator. Yet I stand to my view, that a newbie should not start shooting immediately, but rather dig in the archives to see more of the whole picture. That's even what I do in such cases if I don't know the user well enough.
If unsure a post can still be reported and then a moderator can look at it.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Hologram
Posts: 201
Joined: Thu Nov 03, 2022 3:05 pm

Re: [Sketcher] snapping discussion

Post by Hologram »

chrisb wrote: Thu Feb 09, 2023 5:02 am
adrianinsaval wrote: Wed Feb 08, 2023 9:40 pm moderators are people too so not without fault, IMO it's ok to call out someone's behavior even if they are a moderator
You are of course very right here with this very general statement. That's why I didn't say that it is not allowed to criticize a moderator. Yet I stand to my view, that a newbie should not start shooting immediately, but rather dig in the archives to see more of the whole picture. That's even what I do in such cases if I don't know the user well enough.
If unsure a post can still be reported and then a moderator can look at it.
The only thing I'll say is that it definitely was not the moment to call a moderator, the comment was nothing too serious for that. Sometimes, very short sentences without context can be interpreted as snarky even when well intended. And the history was that a previous thread on the sketcher offset started going downhill fast after one such comment. To me this is way more drama then necessary, I'm out.
User avatar
paddle
Veteran
Posts: 1364
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Sketcher] snapping discussion

Post by paddle »

GeneFC wrote: Wed Feb 08, 2023 10:06 pm I have seen a number of projects over the years get bogged down by continuous additions. (The addon suggestion above will not be the last one.)

Make a plan, execute, and get some output. The elegance can come later.
Yes I agree, I fell regularly enough in the trap of adding more and more to a PR. Though a few times suggestions were easy to add and really made sense. So it's still ok to hear them out.

Anyway, let's not get sidetracked. I still need to find how to snap to parabolas and hyperbolas (without talking about bspline) and it seems quite difficult.

Currently for hyperbola, how to find the point on the hyperbola close to mouse pointer. I posted on stack exchange the problem in details : https://math.stackexchange.com/question ... arby-point

If it inspires someone with hyperbola knowledge :)
User avatar
paddle
Veteran
Posts: 1364
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Sketcher] snapping discussion

Post by paddle »

The parabola snapping is solved. Big thanks to Glorious Erin who solved it on stackoverflow.
Now onto parabolas.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Sketcher] snapping discussion

Post by abdullah »

paddle wrote: Thu Feb 09, 2023 1:14 pm The parabola snapping is solved. Big thanks to Glorious Erin who solved it on stackoverflow.
Now onto parabolas.
Isn't this what you are looking for:

GeomCurve::closestParameter(const Base::Vector3d& point, double &u)
+
GeomCurve::pointAtParameter(double u);

That would work for all curves.

Edit: It is GeomCurve, not Geometry.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Sketcher] snapping discussion

Post by abdullah »

paddle wrote: Tue Feb 07, 2023 8:56 pm Ok so it works as expected and it is mostly (see PR) done.

@abdullah I posted a draft PR so that you can see if the architecture match the expectations :
https://github.com/FreeCAD/FreeCAD/pull/8387
I am redoing another PR now, so it will take me some time before I can move to this one right away.

By then, your PR will be likely finished.

Remember: One feature. Just one feature at a time.

- Have your feature tested thoroughly.
- When you are finished with the functionality, read your code. Try to look for code improvements. Be critical.
User avatar
paddle
Veteran
Posts: 1364
Joined: Mon Feb 03, 2020 4:47 pm

Re: [Sketcher] snapping discussion

Post by paddle »

abdullah wrote: Thu Feb 09, 2023 2:52 pm Isn't this what you are looking for:

GeomCurve::closestParameter(const Base::Vector3d& point, double &u)
+
GeomCurve::pointAtParameter(double u);

That would work for all curves.

Edit: It is GeomCurve, not Geometry.
Holy moly. It works, it's so simple.

Code: Select all

double pointParam;
auto curve = static_cast<const Part::GeomCurve*>(geo);
curve->closestParameter(pointToOverride, pointParam);
pointToOverride = curve->pointAtParameter(pointParam);
It works with all curves, including bspline.
Post Reply