Edge midpoint fix
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Edge midpoint fix
Hello,
I have noticed that if "Edge midpoint" cosmetic vertex is added to an edge constituted by a Bezier curve, it is not placed in the half way between endpoints, but slightly off. Thus I have created Pull Request #4878 to fix this behavior. For better idea, here's the illustrating picture:
CurrentMidPoint = how the midpoint is currently added
FixedMidPoint = how the midpoint is placed according to my pull request
In case of any comments, issues or suggestions, please let me know.
Kind regards,
Tomas
I have noticed that if "Edge midpoint" cosmetic vertex is added to an edge constituted by a Bezier curve, it is not placed in the half way between endpoints, but slightly off. Thus I have created Pull Request #4878 to fix this behavior. For better idea, here's the illustrating picture:
CurrentMidPoint = how the midpoint is currently added
FixedMidPoint = how the midpoint is placed according to my pull request
In case of any comments, issues or suggestions, please let me know.
Kind regards,
Tomas
Re: Edge midpoint fix
Hmmm. Your solution seems to me worse than the original one... What is the criteria decide the center of the spline ?
Re: Edge midpoint fix
Hi,
in my pull request the midpoint criterium is the actual path length. The lengths of the trajectories from the midpoint to the endpoints are the same, thus midpoint is really "halving" the curve.
The current solution basically takes the average of curve endpoint parameters to compute the midpoint. This works well for curves of constant velocity (lines, arcs of circles), however gives wrong results for Bezier curves, arcs of ellipses etc. where the velocity changes along the path.
This is not much about esthetics, but rather about midpoint definition.
Kind regards,
Tomas
in my pull request the midpoint criterium is the actual path length. The lengths of the trajectories from the midpoint to the endpoints are the same, thus midpoint is really "halving" the curve.
The current solution basically takes the average of curve endpoint parameters to compute the midpoint. This works well for curves of constant velocity (lines, arcs of circles), however gives wrong results for Bezier curves, arcs of ellipses etc. where the velocity changes along the path.
This is not much about esthetics, but rather about midpoint definition.
Kind regards,
Tomas
Re: Edge midpoint fix
Do you mean you take the mid-path length of the 3D representation ? Or of the 2D representation ?
Re: Edge midpoint fix
A good fix! When i saw the screenshot with the correct one, i looks also a little bit false. But i measure it with the caliper on the screen and it seems correct to me.
Greetings
user1234
Greetings
user1234
Re: Edge midpoint fix
I was asked to review your PR and since I don't have the time right now to compile, I can at least say, the code looks good and reasonable.
However, and this is what I always say : Add comments!
Others should get what you are doing and why also years later. So please add comments why you use GCPnts_AbscissaPoint::Length. You can also refer in the comment to this thread.
Concerning the concerns here in previous posts, you could make a screenshot with arcs, then it should become more clear what the problem is.
However, and this is what I always say : Add comments!
Others should get what you are doing and why also years later. So please add comments why you use GCPnts_AbscissaPoint::Length. You can also refer in the comment to this thread.
Concerning the concerns here in previous posts, you could make a screenshot with arcs, then it should become more clear what the problem is.
Re: Edge midpoint fix
Hello,
The arc length is 105.05mm (could be verified using online ellipse circumference calculators), thus the midpoint should be placed 52,525mm from both start and end points when tracing the arc. While the current implementation is clearly off, the dimensions in the proposed fix indicate correct placement.
Kind regards,
Tomas
Sure, understood. I have added a new commit with a few comments to describe what's going on.
Ok, here is another example. Arc of ellipse, longer axis is horizontal, shorter axis vertical, simple 1st quadrant arc. "ParameterAverageMidpoint" shows where the midpoint is added now, "HalvedLengthMidpoint" shows the proposed fix:
The arc length is 105.05mm (could be verified using online ellipse circumference calculators), thus the midpoint should be placed 52,525mm from both start and end points when tracing the arc. While the current implementation is clearly off, the dimensions in the proposed fix indicate correct placement.
Kind regards,
Tomas
Re: Edge midpoint fix
Many thanks for your improved PR. I approved it.
Yes, the PR fixes the bug correctly. Here an example from me:
- the midpoint close to the center of the spline is the one with the PR, the one more to the right is the one without the PR.
@tpavlicek, while you are at coding midpoints, could you perhaps a look why the addition of midpoints cannot be undone like every other FreeCAD feature?
Yes, the PR fixes the bug correctly. Here an example from me:
- the midpoint close to the center of the spline is the one with the PR, the one more to the right is the one without the PR.
@tpavlicek, while you are at coding midpoints, could you perhaps a look why the addition of midpoints cannot be undone like every other FreeCAD feature?
Re: Edge midpoint fix
Good evening to the Community!
I thought it appropriate to reply to clarify some (of inaccuracies indicated as bugs).
In TechDraw the possibility of identifying the center of a spline and / or a curve and / or a compound curve is not contemplated, the function "create center line with two vertices" does not have this purpose, but only that of drawing a line centrally orthogonal to the two vertices chosen according to option: vertical, horizontal or aligned.
In my opinion we are wrong to underestimate FreeCad thinking that it is not able to accurately identify the midpoint of any spline and / or compound curve [tpavlicek writes:… ..The arc length is 105.05mm (could be verified using online ellipse circumference calculators ) ……] probably because he has not thoroughly studied the tools available to FreeCad.
Just use the “Curves” workbench and everything returns to “normal”.
In the following images a trivial example of the power and versatility of FreeCad regarding ellipses and splines (try to experiment if it is also possible with other famous commercial cads).
If the curve (or compound curve) can be identified as an arc, then its length can also be indicated as a development in TechDraw using the macro "TechDrawTools V 0.4.2-multilanguage" by @edi and domad, otherwise to know the parameters we can use another macro "FCInfo_en_Ver_1-22-rmu_Docked" by @ mario52 that will give us a lot of information ... .. exportable in different table formats.
I hope I was helpful.
Happy weekend to the community!
I thought it appropriate to reply to clarify some (of inaccuracies indicated as bugs).
In TechDraw the possibility of identifying the center of a spline and / or a curve and / or a compound curve is not contemplated, the function "create center line with two vertices" does not have this purpose, but only that of drawing a line centrally orthogonal to the two vertices chosen according to option: vertical, horizontal or aligned.
In my opinion we are wrong to underestimate FreeCad thinking that it is not able to accurately identify the midpoint of any spline and / or compound curve [tpavlicek writes:… ..The arc length is 105.05mm (could be verified using online ellipse circumference calculators ) ……] probably because he has not thoroughly studied the tools available to FreeCad.
Just use the “Curves” workbench and everything returns to “normal”.
In the following images a trivial example of the power and versatility of FreeCad regarding ellipses and splines (try to experiment if it is also possible with other famous commercial cads).
If the curve (or compound curve) can be identified as an arc, then its length can also be indicated as a development in TechDraw using the macro "TechDrawTools V 0.4.2-multilanguage" by @edi and domad, otherwise to know the parameters we can use another macro "FCInfo_en_Ver_1-22-rmu_Docked" by @ mario52 that will give us a lot of information ... .. exportable in different table formats.
I hope I was helpful.
Happy weekend to the community!
- Attachments
-
- arc_length_dimensioning.png (153.08 KiB) Viewed 2090 times
-
- spline_midpoint_with_wb_Curves.png (161.57 KiB) Viewed 2098 times