Intersection of 2 (too small) circles (or arcs)

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
CVH
Premier Member
Posts: 3419
Joined: Wed Sep 27, 2017 4:17 pm

Intersection of 2 (too small) circles (or arcs)

Post by CVH » Tue Sep 28, 2021 10:19 am

Andrew,

I know I have to elaborate my final paragraph in the topic:
https://qcad.org/rsforum/viewtopic.php?f=33&t=8773
But its too early for that and at the moment I can't be complete ... :oops: Sorry.

Although everyone will see where these (too) small circles do or do not intersect, I can foresee your answer here:
"QCAD can't handle these circles/arcs properly"
And yes, if it was possible I would already have chosen microns as unit.
These are only snippets from a larger design and as circles there the same logic applies.

IntersectionTwoTooSmallCircles.dxf
(98.52 KiB) Downloaded 311 times
With the attached dxf: (Auto zoom on load doesn't zoom in)
Select All (TA), zoom to Selection (ZS), Deselect All (TN)
Select Line from 2 Points (LI) ... Select snapping to intersections (SI)
Then hover over the pairs of circles close at the (near) intersections.

What happens is that these circles are all considered to be tangent pairwise within a fixed tolerance.
And the intersection of circles is always on the larger one if not of equal size.
See RShape.getIntersectionPointsCC: Tolerance = 1e-4 ; Sorting circles shapes by size.

Is there a better approach?
Not at this moment but I have isolated one rare case that can be avoided.
Concentric circles/arcs with a delta in radius smaller than the tolerance are also considered to be tangent.
The tangent or intersection point is then fixed at 0°of the larger circle/arc. (The Rvector u ≈ (0,0,0,1))

Solution:
In RShape.getIntersectionPointsCC the concentrically test at line 1072-1075 should be promoted to be the first test.
https://github.com/qcad/qcad/blob/f4b8b ... .cpp#L1072

Regards,
CVH

CVH
Premier Member
Posts: 3419
Joined: Wed Sep 27, 2017 4:17 pm

Re: Intersection of 2 (too small) circles (or arcs)

Post by CVH » Sun Oct 10, 2021 12:36 pm

Andrew,
thanks for reading the topic :P and the recent commits:

Sep 30, 2021: https://github.com/qcad/qcad/commit/77a ... d273768449
- Promoted the concentric test to first in line. 8)
- Implemented a relative tolerance = 1 part per thousand of the average radius.
Oct 1, 2021: https://github.com/qcad/qcad/commit/071 ... d273768449
- Updated tolerance to 10 parts per million of the average radius.

I need to let that sink in for a while ... :wink:
The relative tolerance should have a profound impact on what are considered to be tangent circles or arcs.
And thus on all QCAD methods that rely on tangent circles/arcs intersections.

The tolerance value is also used to filter out 2 almost equal solutions. (Line 1100 ...)
I can not envision two circles not considered tangent and with two distinct intersections that are less than the tolerance apart. :?
IntersectingCircles2Solutions vs Tolerance.dxf
(112.41 KiB) Downloaded 290 times
IMHO the RVector near equality test will always return 'False'.

For a sum of radii larger than 20 units the relative tolerance exceeds the former fixed tolerance of 1e-4.
At some point the tolerance may even exceed the smallest radius ... diameter ... :?

Like I said, I have no closed format for this issue.
The further a point is from the origin, the lower its positional accuracy in floating point notation will be.
What also counts for all points on a circle wherever that is located.

Now all depends on how round a circle will be when represented in the limited binary Cartesian grid given its radius and its location.
In floating point the roundness itself is a quite chaotic relation:

RoundnessR100D2550.png
RoundnessR100D2550.png (85.39 KiB) Viewed 4595 times

And it tends to increase more with position than with size.
As example a circle R=1 @(400,400) is round to within 3.73e-14 units tested every degree from 0 to 359.
But very far from the origin e.g. @(4e12,4e12) it is only round to within 3.13e-4 units or 0.3%.

Summary:
Any intersection point is only the best local representation of a point on the larger circle/arc.
Intersection points are not guaranteed to be on the smaller circle/arc.

For the case that I have at hand: When trimming two arc shapes pair-wise ...
... Then only the orientations to these intersections are required there an arc shape has ending angles and not ending points.
These angles are found by solving a convex or concave KITE shape.
The advantage is that orientations have a steady uncertainty not larger than 9e-16 throughout the plane.

Regards,
CVH

John Hyslop
Premier Member
Posts: 473
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Intersection of 2 (too small) circles (or arcs)

Post by John Hyslop » Sat Nov 27, 2021 5:38 am

Hi CVH

I just downloaded your dxf file and maybe I'm not understanding?
I can snap to the intersections of the small circles :?
See Gif Below..

Cheers
John
PS
QCAD/CAM
Version: 3.26.4.13 (3.26.4.13)
Internet: QCAD.org
Build Date: Nov 18 2021
Revision: fbb9f37
Qt Version: 5.8.0
Architecture: x86_64
Compiler: gcc 4.8.1
Attachments
2_small_arcs.gif
2_small_arcs.gif (2.09 MiB) Viewed 3923 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

CVH
Premier Member
Posts: 3419
Joined: Wed Sep 27, 2017 4:17 pm

Re: Intersection of 2 (too small) circles (or arcs)

Post by CVH » Sat Nov 27, 2021 6:44 am

John,
See changes made by Andrew reported in the second post. (A silent bug fix, if you like)
The issue existed with a fixed tolerance of 1e-4.
Any distance below that was considered tangent resulting in one single point on a line between both centers.
And always on the larger circle.

Andrew fixed that with a relative tolerance given the 2 radii in question.

So yes, it works now for those small circles in the example dxf.
These are no longer considered to be tangent pair-wise and 2 or no intersection points are returned.
Letting us snapping to the real intersection points like you report. :P

It was all an issue with the RoundPolylineCorners Addon of which you possess a copy.
That also rounds correct between two non-tangent arcs or between non-tangent arcs and lines.
This requires the intersection of lines or arcs vs an arc and that is done by circle intersection.

I also mention that this may have a profound impact on what is considered as tangent circles ... and arcs. :?

There was no follow up because the Addon sits dead in the water.
Related to how QCAD merges (OG, OC, OL) an arc shape to a polyline in general.
I think that you already know the rest of the story. :wink: ... connect tolerance + plain copy of the arc bulge factor ...

Regards,
CVH
Last edited by CVH on Sat Nov 27, 2021 8:40 am, edited 2 times in total.

John Hyslop
Premier Member
Posts: 473
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Intersection of 2 (too small) circles (or arcs)

Post by John Hyslop » Sat Nov 27, 2021 7:03 am

Thanks CVH

It didn't have solved in the title and I thought I was going mad or had a superior version of Qcad :lol:

Cheers
John
PS RoundPolyLineCorners I'm using quite a lot... :D
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

CVH
Premier Member
Posts: 3419
Joined: Wed Sep 27, 2017 4:17 pm

Re: Intersection of 2 (too small) circles (or arcs)

Post by CVH » Sat Nov 27, 2021 7:59 am

John Hyslop wrote:
Sat Nov 27, 2021 7:03 am
It didn't have solved in the title
Kinda solved :wink:
Follow up CC intersection.dxf
For QCAD versions released after Oct 1, 2021
(97.66 KiB) Downloaded 271 times

Regards,
CVH

Post Reply

Return to “QCAD Troubleshooting and Problems”