LibreCAD / LibreCAD

LibreCAD is a cross-platform 2D CAD program written in C++17. It can read DXF/DWG files and can write DXF/PDF/SVG files. It supports point/line/circle/ellipse/parabola/spline primitives. The user interface is highly customizable, and has dozens of translations.
http://librecad.org/
Other
4.47k stars 1.01k forks source link

Break Divide tool does not recognize circles when using tangent lines #1918

Closed Questions2000 closed 4 weeks ago

Questions2000 commented 1 month ago

Linux / Appimage alpha

First off, the break/divide tool that has been added is amazing! I finally got around to testing it out a little and really cannot believe it, I really want to say a lot more about how great this tool is but want to keep this post as short as possible :) just thank you very much for adding this.

For now I just want to mention something that I noticed, that may already be known, I apologize if it is. I noticed that when using "tangent line" based tools with circles that the break/divide tool does not recognize the pieces of some of the circles. I first noticed this when using the "tangent line" tool that adds a predetermined tangent line to a circle.

I then noticed this with "tangent line CC" tool which I will share example of how to reproduce.

Steps to reproduce

(All drawing settings are the default new document settings) -draw a horizontal line with length 200 -draw a circle with radius 50 with the center point at the left endpoint of the line -draw a circle with radius 100 with the center point at the right endpoint of the line -delete the line 200 -tangent CC tool draw line top of left circle to top of right circle -tangent CC tool draw line bottom of left circle to bottom of right circle So now this should appear to form one combined shape -use break/divide tool to try and cut the inner parts of the circles between the tangent lines out In this example it will let you actually cut both circles out.

Other Results Noticed

Depending on the circle size and lines you will see different results..... -Sometimes neither will be recognized by the tool, for example if the circles are the same size. -Sometimes only one of the circles will recognize that it can be trimmed -Sometimes both will recognize that they can be trimmed but if you perform one trim then the other circle no longer recognizes that it can be trimmed.

Hope this helps Thank You again for adding this tool

sand1024 commented 1 month ago

Thank you for your positive feedback.

Well, I think the issue there is rather more complex. Actually, the "Break/Divide" tool relies on detected intersection points between entities.

For this special case (tangent line to circle) - the intersection point between line and circle intersection's detection may be not too reliable (say, during calculations some floating point value may become less than supported tolerance factor).

Basically, the same situation may occur for "Trim" command too, I suppose.

So while the overall logic of the tool is correct, the generic logic of determining intersection points should be improved.

Anyway, thank you for your hint, there is definitely a room for improvements.

Questions2000 commented 4 weeks ago

@dxli Thank you for looking into and thumbs up

@sand1024 Thank you for looking into it and again for creating this tool. I figured it had something to do with how the lines connected with tangent lines. What confused me though is that the first circles center section does actually trim out and delete, so it is strange that when you try it with the other circle which is in essence the same action, then it does not work (hopefully this makes sense).

Thanks again

sand1024 commented 4 weeks ago

could you please make a small drawing with this case and share it there? Probably it may be related to angles and radiuses values, so actual example will be helpful.

lordofbikes commented 4 weeks ago

Probably related:

523

https://forum.librecad.org/cannot-snap-intersection-of-two-inscribed-ellipses-td5725436.html

And there are probably more threads and issues addressing this.

Recent post from @dxli hit the bulls eye.

Another workaround is to create a temporary orthogonal line through the circle center and use its intersection. There is much less room for tolerance issues with orthogonal intersections.

Questions2000 commented 3 weeks ago

@sand1024 Here is a good example, I put some time into this post already, but lets say I went even further and filled in all the categories in the template and provided images, etc. would it have been worth it? The conversation was with you and the tool you have provided, you sounded like it might be something you might look into in the future.

The link that was shown is to the forum so there might not be a ticket here on Github to look into the issue because this post was closed, based on probablies? "Not Planned", maybe not by our lord, but maybe by you or other developers? So why not keep this open? Again I am not a developer so I have no idea, but seems strange. Does the tool you have provided have any connection to the link that was given?

I also have mentioned that it does work for one of the circles, so would think it would be worth keeping this post open for a little while to look into it, rather than closing? I can replicate it. In the tests that I performed this worked with the different size circles which is why I did not say specific sizes and did not know it was because of angles at the time, but it could be like you said.

So what should I do? Any chance this could be reopened, if not just to let the people having the discussion, finish it and decide to close it after? Let me know

Questions2000 commented 3 weeks ago

Anyone interested can try the new example I made in the original thread post at the top. This example allows both circles to be trimmed using this tool.

Questions2000 commented 2 days ago

@sand1024 Sorry to tag you but because this issue has been closed just wanted to make sure this was seen. Not sure if this has been worked on, but in testing this, it seems to work a lot more then it did all of sudden.

In testing have not been able to generate any instances where neither circle can be trimmed and only once did I get it to generate a scenario where only one circle accepts the trim.

I was just wondering if this was worked on, if not, then something happened which made this work better.

If this was worked on by you (or any other developers), just wanted to let you know that I noticed and thank you for updating this, I appreciate it.

sand1024 commented 1 day ago

@Questions2000 Yes, internal algorithm for trimming circles was improved, and as side effect of such improvement "Break/Divide" command behaves better now.

YET! if you see that there is still a scenario with invalid cut of circle - please report it as your did it before (with specific sizes and locations) or please just attach example dbf file with such case.