I implemented the gathered knowledge from the former topic to ArcTPR.js to no avail.

Intersections between a newly created Fit-Point spline shape and a circle remains empty. (Case1)
And just the same with swapping the shapes. (Case2)

But then I stumbled on the fact that Case2 was valid --ONLY AFTER-- trying to query intersections for Case1.
There are thus Intersections found for a second attempt with the same shapes.

A newer test script proved that:
Something changes for the spline shape after a first attempt to get intersections points.
What exactly can be determined from Case C.1 and Case C.2.
After a first attempt there are Control Points reported besides the Fit Points:
... Trial 2: Shape 3 has Fit-Points: true (+CP)
Suspecting this is related with an internal update of the shape.
An update() is already performed when adding Fit-Points. (Reference)
updateInternal() is a Protected Member Functions and can't be called in direct.
This can however be initiated by other functions:
- RSpline.copySpline() or .getControlPointsWrapped(); .getActualKnotVector()
.getDirection1() or getDirection2()
.getExploded(segments); .getPointAt(t)
.getTMin() or getTMax()
.getDiscontinuities(); .getBezierSegments(queryBox)
An updateInternal() is done and the spline additionally has Control-Points while it was created with Fit-Points.
Finding intersections between a spline with Control-Points and a circle is functional.

The test script that can be run with: Misc .. Development .. Run Script (XC):
The code of this script in textual form:
Code: Select all
// Example points to fit:
var fitPoints = [new RVector(0, 9),
new RVector(7, 0),
new RVector(0, -9),
new RVector(-7, 0)];
// Create an RSpline shape:
var spline1 = new RSpline();
spline1.setFitPoints(fitPoints);
spline1.setPeriodic(true);
// Create a RCircle shape:
var circle1 = new RCircle(RVector.nullVector, 8.0);
// Get intersections of RSpline and RCircle, expecting 4:
var ips1a = spline1.getIntersectionPoints(circle1, false);
// Report the number of intersections on the Command History:
EAction.handleUserWarning("1.1: As fit-point spline 1 and circle: %1 intersections (of 4)".arg(ips1a.length));
// SECOND ATTEMPT
EAction.handleUserInfo("Re-query");
// Get intersections of RSpline and RCircle, expecting 4:
var ips1b = spline1.getIntersectionPoints(circle1, false);
// Report the number of intersections on the Command History:
EAction.handleUserInfo("1.2: Again as fit-point spline 1 and circle: %1 intersections (of 4)".arg(ips1b.length));
// START OVER NEW
EAction.handleUserInfo("");
// Create an RSpline shape:
var spline2 = new RSpline();
spline2.setFitPoints(fitPoints);
spline2.setPeriodic(true);
// Create a RCircle shape:
var circle2 = new RCircle(RVector.nullVector, 8.0);
// Get intersections of RCircle and RSpline, expecting 4:
var ips2a = circle2.getIntersectionPoints(spline2, false);
// Report the number of intersections on the Command History:
EAction.handleUserWarning("2.1: As circle and fit-point spline 2: %1 intersections (of 4)".arg(ips2a.length));
// SECOND ATTEMPT
EAction.handleUserInfo("Re-query");
// Get intersections of RCircle and RSpline, expecting 4:
var ips2b = circle2.getIntersectionPoints(spline2, false);
// Report the number of intersections on the Command History:
EAction.handleUserInfo("2.2: Again as circle and fit-point spline 2: %1 intersections (of 4)".arg(ips2b.length));
// Case 1.2 and 2.2 are functional ... What has changed for the second attempt?
// START OVER NEW
EAction.handleUserInfo("");
// Create an RSpline shape:
var spline3 = new RSpline();
spline3.setFitPoints(fitPoints);
spline3.setPeriodic(true);
// Create a RCircle shape:
var circle3 = new RCircle(RVector.nullVector, 8.0);
// Report some details of the RSpline shape:
var isSpl = isSplineShape(spline3).toString();
EAction.handleUserInfo("... Trial 1: Shape 3 is a spline shape: %1".arg(isSpl));
var hasFP = "undefined"
if (isSpl) {
if (spline3.hasFitPoints()) {
hasFP = "true"
}
if (spline3.countControlPoints() > 0) {
hasFP += " (+CP)"
}
else {
hasFP += " (noCP)"
}
}
EAction.handleUserInfo("... Trial 1: Shape 3 has Fit-Points: %1".arg(hasFP));
// Get intersections of RSpline and RCircle, expecting 4:
var ips3a = spline3.getIntersectionPoints(circle3, false);
// Report the number of intersections on the Command History:
EAction.handleUserWarning("3.1: As fit-point spline 3 and circle: %1 intersections (of 4)".arg(ips3a.length));
// SECOND ATTEMPT
EAction.handleUserInfo("Re-query");
// Report some details of the RSpline shape:
var isSpl = isSplineShape(spline3).toString();
EAction.handleUserInfo("... Trial 2: Shape 3 is a spline shape: %1".arg(isSpl));
var hasFP = "undefined"
if (isSpl) {
if (spline3.hasFitPoints()) {
hasFP = "true"
}
if (spline3.countControlPoints() > 0) {
hasFP += " (+CP)"
}
else {
hasFP += " (noCP)"
}
}
EAction.handleUserInfo("... Trial 2: Shape 3 has Fit-Points: %1".arg(hasFP));
// Get intersections of RSpline and RCircle, expecting 4:
var ips3b = spline3.getIntersectionPoints(circle3, false);
// Report the number of intersections on the Command History:
EAction.handleUserInfo("3.2: As fit-point spline 3 and circle: %1 intersections (of 4)".arg(ips3b.length));
// Case 3.2 is functional because after the first query it reports to have Control-Points as well
// Can we force that?
// updateInternal() is a Protected Member Functions
// It can however be initiated by other functions:
// RSpline.copySpline(RSpline)
// RSpline.getControlPointsWrapped()
// RSpline.getActualKnotVector()
// RSpline.getDirection1() or getDirection2()
// RSpline.getExploded(segments)
// RSpline.getPointAt(t)
// RSpline.getTMin() or getTMax()
// RSpline.getDiscontinuities()
// RSpline::getBezierSegments(queryBox)
// START OVER NEW
EAction.handleUserInfo("");
// Create an RSpline shape:
var spline4 = new RSpline();
spline4.setFitPoints(fitPoints);
spline4.setPeriodic(true);
// Create a RCircle shape:
var circle4 = new RCircle(RVector.nullVector, 8.0);
// Force an updateInternal():
var dummy = spline4.getTMin();
// Get intersections of RSpline and RCircle, expecting 4:
var ips4 = spline4.getIntersectionPoints(circle4, false);
// Report the number of intersections on the Command History:
EAction.handleUserMessage("4: As (updated) fit-point spline 3 and circle: %1 intersections (of 4)".arg(ips4.length));
EAction.handleUserMessage("=> Issue found and fixed")
// Report end of script (If we get this far):
EAction.handleUserInfo("Script end");
CVH