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 {
29
29
const maxLength = 5 ; //每一小段的最大长度
30
30
let num = 1 ;
31
31
for ( ; s / num > maxLength ; num ++ ) ;
32
+ // console.log("Curve segments: " + num);
32
33
for ( let i = 0 , t0 = 0 ; i < num - 1 ; i ++ ) {
33
34
for ( let left = t0 , right = 1 ; ; ) {
34
35
const t = left + ( right - left ) / 2 ;
35
36
const point = funcs . equation ( t ) ;
36
- const requiredError = 0.5 ;
37
+ const requiredError = 0.25 ;
37
38
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);
38
41
const diff = dist - s / num ;
42
+ // console.log("segment " + (i + 1) + "/" + num + " diff: " + diff);
39
43
if ( Math . abs ( diff ) < requiredError ) {
40
44
result . push ( point ) ;
41
45
t0 = t ;
@@ -45,7 +49,9 @@ export class CublicCatmullRomSpline extends Shape {
45
49
} else {
46
50
right = t ;
47
51
}
52
+ // console.log("segment " + (i + 1) + "/" + num + " t: " + t);
48
53
}
54
+ // console.log("segment " + (i + 1) + " compelete");
49
55
}
50
56
result . push ( funcs . equation ( 1 ) ) ;
51
57
}
Original file line number Diff line number Diff line change 50
50
$$
51
51
s=\int_0^1 \lvert {\boldsymbol{p}}^{'} \rvert dt
52
52
$$
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