File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
app/src/core/dataStruct/shape Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,17 @@ export class CublicCatmullRomSpline extends Shape {
2929 const maxLength = 5 ; //每一小段的最大长度
3030 let num = 1 ;
3131 for ( ; s / num > maxLength ; num ++ ) ;
32+ // console.log("Curve segments: " + num);
3233 for ( let i = 0 , t0 = 0 ; i < num - 1 ; i ++ ) {
3334 for ( let left = t0 , right = 1 ; ; ) {
3435 const t = left + ( right - left ) / 2 ;
3536 const point = funcs . equation ( t ) ;
36- const requiredError = 0.5 ;
37+ const requiredError = 0.25 ;
3738 const dist = point . distance ( result [ result . length - 1 ] ) ;
39+ // const dist =
40+ // (t - t0) * NumericalIntegration.romberg((x) => funcs.derivative(x * (t - t0) + t0).magnitude(), 0.1);
3841 const diff = dist - s / num ;
42+ // console.log("segment " + (i + 1) + "/" + num + " diff: " + diff);
3943 if ( Math . abs ( diff ) < requiredError ) {
4044 result . push ( point ) ;
4145 t0 = t ;
@@ -45,7 +49,9 @@ export class CublicCatmullRomSpline extends Shape {
4549 } else {
4650 right = t ;
4751 }
52+ // console.log("segment " + (i + 1) + "/" + num + " t: " + t);
4853 }
54+ // console.log("segment " + (i + 1) + " compelete");
4955 }
5056 result . push ( funcs . equation ( 1 ) ) ;
5157 }
Original file line number Diff line number Diff line change 5050$$
5151s=\int_0^1 \lvert {\boldsymbol{p}}^{'} \rvert dt
5252$$
53+
54+ $$
55+ s(t_0, t_1) = \int_{t_0}^{t_1} \lvert {\boldsymbol{p}}^{'} \rvert dt = (t_1-t_0) \int_0^1 \lvert {\boldsymbol{p}}^{'}(x(t_1-t_0)+t_0)\rvert dx
56+ $$
57+
58+ 其中
59+
60+ $$
61+ x = \frac{t-t_0}{t_1-t_0}
62+ $$
You can’t perform that action at this time.
0 commit comments