FS#2736REllipse::correctMajorMinor() calls itself one more time, switchMajorMinor() calls it twice
- Type
- Refactoring
- Status
- Closed
- Resolution
- Implemented
- Category
- QCAD (main)
- Severity
- Low
- Priority
- Low
- Reported version
- 3.32.9
- Operating system
- All
- Reported
- 2026-07-30 by CVH
- Closed
- 2026-07-30 by andrew
Andrew,
Claude included major/minor swapping in REllipse::getVectorTo().
This is an existent resource and already used in most cases.
I never encountered a major radius less than the minor but it is plausible.
For a ratio over 1.0, correctMajorMinor() caches the minor point (Line 1205).
Sets a corrected ratio (Line 1206).
And then it sets the major point using REllipse::setMajorPoint() (Line 1207).
setMajorPoint() calls REllipse::correctMajorMinor() again.
This time the ratio is less than 1.0 and nothing is altered.
Because correctMajorMinor() is setting things straight it can simply update
the public attributes: 'ratio', 'majorPoint', 'startParam' and 'endParam' in this order.
correctMajorMinor() is typically called for:
- The valid REllipse constructor.
- When setting the REllipse major point, the ratio
and thus also when setting the minor point.
- When setting the properties of an REllipseEntity.
There is a second analog to REllipse::correctMajorMinor().
The method REllipse::switchMajorMinor() does practically the same but then based on an external test.
In open source only used in RShape::getIntersectionPointsEE (Line 1275 and 1279).
Then called when the major radius is less than the minor radius.
The main difference is that it is skipped when the ratio is less than 1e-9.
fabs(ratio) in line 314 is odd because a negative ratio is invalid ... Not rendered.
switchMajorMinor() triggers correctMajorMinor() twice.
It first set the major point equal to the minor point based on the former ratio.
This triggers correctMajorMinor().
Then it sets the reciprocal of the ratio.
This also triggers correctMajorMinor().
switchMajorMinor() can also update the public attributes in direct.
For the record: REllipse::getTangents also swaps major/minor in direct when the point is on the minor axis. This method handles an ellipse as full and doesn't correct end parameters.
Regards,
CVH
Comments (1)
Here's what Claude made of this:
https://github.com/qcad/qcad/commit/4fb58fe9b9dce5259c7f2368830c211258fdd866