FS#1783RArc::splitAt(): fails in some cases
- Type
- Bug
- Status
- Closed
- Resolution
- Fixed
- Category
- QCAD (main)
- Severity
- Low
- Priority
- Low
- Reported version
- 3.21.2
- Operating system
- All
- Reported
- 2018-07-16 by HungryLion
- Closed
- 2018-07-16 by andrew
RArc::splitAt() works wrong in some cases.
To reproduce execute this script:
var arc = new RArc(new RVector(0, 0), 100, Math.PI*2, Math.PI/2, true);
var points = [];
points.push(arc.getPointAtPercent(1/3));
var arcs = arc.splitAt(points);
if (arcs.length == 2) {
qDebug("OK, arcs count:", arcs.length);
} else {
qDebug("FAILED, arcs count:", arcs.length);
}
arc.mirror(new RLine(0, 0, 0, 100));
points = [];
points.push(arc.getPointAtPercent(1/3));
arcs = arc.splitAt(points);
if (arcs.length == 2) {
qDebug("OK, arcs count:", arcs.length);
} else {
qDebug("FAILED, arcs count:", arcs.length);
}
The first case split in two arcs, but the second splits in one arc only.
I think the reason is the code in RArc::splitAt():
...
if (RMath::getAngleDifference180(a1, a2))*radius()<0.001) {
continue;
}
...
The RMath::getAngleDifference180() return angle between -pi and pi so absolute value should be used.