Apollonius and 7 solutions

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

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

Apollonius and 7 solutions

Post by CVH » Thu Nov 14, 2024 8:47 am

Stumble on 7 solutions for an Apollonius' Problem what is said to be impossible.

As user we won't notice it, we see only 6 solutions proposed, two are almost identical.
The nearest when indicating one of this pair is arbitrary.
Still, there will be one solution that is better than the other.

After research it turns out that this is not limited to 6-7, it can occur whenever there are more solutions.
What happens is that two, typically large solutions, are NOT considered as equal and both are verified to be reasonable tangent.

Again a fixed tolerance is the culprit.
Center and radius NOT equal within RS.PointTolerance = 1e-9 units.
Both are tangent to the given system within RS.PointTolerance.

Typically, squares and roots are exploited and results may vary slightly depending the magnitude of the intermediate values.
Then larger values are less accurate within the Floating Point system.
Various paths result in a larger (>8) collection of candidates.
Of all things, tangent circles are the mathematically more problematic problems.

Comparing solution circles should therefor be done with an adaptive tolerance.
Keeping the best tangent nature of the two solutions when about equal.
Solutions that are identical to a given circle shape of the problem must also be excluded.
Meaning that the functions:
- Apollonius.removeDuplicates
- Apollonius.verify
relying on:
- Apollonius.compareShapes
- Apollonius.shapesTouch
must be merged so that they work in tandem and not one after the other.
verify should not only eliminate false solutions ...
... It must validate a solution with a comparable value for cases of almost duplicates.

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”