FS#2495RLine.isParallel(RLine) may return true for certain non-parallel cases
- Type
- Bug
- Status
- Closed
- Resolution
- Won't fix
- Category
- ECMAScript
- Severity
- Very Low
- Priority
- Low
- Reported version
- 3.28.2
- Operating system
- All
- Reported
- 2023-10-15 by CVH
- Closed
- 2024-06-17 by andrew
- Votes
- 1
Andrew,
It took me a while to find the source of a certain freak bug I encountered.
I used the RLine.isParallel(RLine) as a test for knowing if line segments were parallel or not.
Included below is script code that mimics the functionally of isParallel().
As far as I know isParallel() is nowhere used in the QCAD open source.
Textual only found in RLine.cpp & .h or under: opennurbs, ecmaapi\generated and ecmagenerator\src.
// Example:
// RShape1: RLine(RShape(address: "0xcd70e28"), startPoint: "RVector(969.219858, -171.914894, 0.000000, 1)", endPoint: "RVector(1010.000000, -140.000000, 0.000000, 1)")
// RShape2: RLine(RShape(address: "0x7659770"), startPoint: "RVector(969.219858, -171.914894, 0.000000, 1)", endPoint: "RVector(930.000000, -340.000000, 0.000000, 1)")
----
var aShape1Angle = shape1.getAngle(); // =0.6640461628266838 rad
var aShape2Angle = shape2.getAngle(); // =4.483157047107694 rad
----
// RLine::isParallel(RLine) -> aTest1 || aTest2
var aTest1 = RMath.isSameDirection(aShape1Angle, aShape2Angle); // =false
var aTest2 = RMath.isSameDirection(aShape1Angle, aShape2Angle + Math.PI); // =true
var aTestOr = aTest1 || aTest2; // =>TRUE !?
----
// # BUG # RShape1 is considered as parallel with RShape2
----
// RMath::isSameDirection(dir1, dir2, tol) ... tol = RS.AngleTolerance = 1e-9
// for aTest1 -> ax1Test1 || ax1Test2
var ax1Dif = Math.abs(aShape1Angle - aShape2Angle); // =3.8191108842810104 rad
var ax1Test1 = ax1Dif < 1e-9; // =false
var ax1Test2 = ax1Dif > 2*Math.PI - 1e-9; // =false
var ax1TestOr = ax1Test1 || ax1Test2; // =>FALSE
----
// for aTest2 -> ax2Test1 || ax2Test2
var ax2Dif = Math.abs(aShape1Angle - (aShape2Angle + Math.PI)); // =6.9607035378708035 rad
var ax2Test1 = ax2Dif < 1e-9; // =false
var ax2Test2 = ax2Dif > 2*Math.PI - 1e-9; // =true
var ax1TestOr = ax1Test1 || ax1Test2; // =>TRUE
----
// # BUG # The second test of the second isSameDirection() test returns true because ax2Dif is over 2pi
Regards,
CVH
Comments (1)
I could verify if there is an intersection between the two RLine's.
The question remains at what distance that this is still reasonable valid or not ...
I finally settled for something that is also angle based:
Instead of using:
Regards,
CVH