Uh oh!
There was an error while loading. Please reload this page.
Fixing long splines rendering - #367
Conversation
The change allows correct rendering of quadratic and cubic splines with more than 4 control points by splitting the spline into segments and evaluating each segment as a quadratic or cubic spline, one at a time.
jcoffland
commented
May 26, 2022
This is looking good. exports.insert("SPLINE_CLOSED", 1 << 0);
exports.insert("SPLINE_PERIODIC", 1 << 1);
exports.insert("SPLINE_RATIONAL", 1 << 2);
exports.insert("SPLINE_PLANAR", 1 << 3);
exports.insert("SPLINE_LINEAR", 1 << 4); |
| var degree = spl.degree; | ||
| var points = spl.ctrlPts; | ||
| var knots = spl.knots; | ||
| var weights = []; /* spl.weights; */ for(i=0; i<points.length; i++) { weights.push(1.0); } /* TODO */ |
There was a problem hiding this comment.
The weights are in the DL_ControlPointData structure. The function Reader::addControlPoint()should passctrlPt.wto theaddControlPoint()callback. The weights could then be added tostd::vector DXF::Spline::weightsand then later passed viaDXFModule`` to TPL.
| } | ||
| var steps = Math.ceil(nurbs_length(s) / res); | ||
| //var delta = 1.0 / steps; | ||
| var delta = 0.01; |
There was a problem hiding this comment.
Why not use the value from nurbs_length() here?
There was a problem hiding this comment.
because of the bug you found at line 238 :-D
sorry for pushing in a rush, but that was it for my 30 minutes of coding.
I have one free hour now, I'll address all comments and try to implement closed curves at least.
| for (var i = 1; i <= 100; i++) { | ||
| var u = cubic_bezier(p, 0.01 * i); | ||
| var u = nurbs_interpolate(0.0*i, spl); |
Implemented and tested
cf9d046 to
e2af4b4Compare
The change allows correct rendering of quadratic and cubic splines
with more than 4 control points by splitting the spline into
segments and evaluating each segment as a quadratic or cubic
spline, one at a time.