|
126 | 126 |
|
127 | 127 | saveas(figure(6),"guide_chunkers_interior.png");
|
128 | 128 |
|
| 129 | +%% |
| 130 | +% START CHUNKERFIT |
| 131 | + |
| 132 | +% Sample a smooth curve at random points |
| 133 | +rng(0) |
| 134 | +n = 20; |
| 135 | +tt = sort(2*pi*rand(n,1)); |
| 136 | +r = chnk.curves.bymode(tt, [2 0.5 0.2 0.7]); |
| 137 | + |
| 138 | +% can pass cparams and pref structures, as in |
| 139 | +% chunkerfunc, via the opts structure |
| 140 | +% asking for splitting can be more efficient, dependent on |
| 141 | +% desired tolerance |
| 142 | + |
| 143 | +% first asking for lower precision from chunkerfunc |
| 144 | +opts = []; |
| 145 | +opts.ifclosed = true; |
| 146 | +opts.cparams = []; |
| 147 | +opts.cparams.eps = 1e-3; |
| 148 | +opts.pref = []; |
| 149 | +opts.pref.k = 16; |
| 150 | +chnkr = chunkerfit(r, opts); |
| 151 | + |
| 152 | +% automatically creates a chunker between each node |
| 153 | +opts.splitatpoints = true; |
| 154 | +chnkrsp = chunkerfit(r, opts); |
| 155 | + |
| 156 | +% then asking for more precision from chunkerfunc |
| 157 | +opts.cparams.eps = 1e-9; |
| 158 | +opts.splitatpoints = false; |
| 159 | +chnkr2 = chunkerfit(r, opts); |
| 160 | + |
| 161 | +% automatically creates a chunker between each node |
| 162 | +opts.splitatpoints = true; |
| 163 | +chnkrsp2 = chunkerfit(r, opts); |
| 164 | + |
| 165 | +figure(7) |
| 166 | +clf |
| 167 | +tiledlayout(2,2,"TileSpacing","compact"); |
| 168 | +nexttile; plot(chnkr,'k-x'); title(sprintf("nch = %d, eps=1e-3",chnkr.nch)); |
| 169 | +hold on; plot(r(1,:),r(2,:),'bd'); |
| 170 | +nexttile; plot(chnkrsp,'k-x'); title(sprintf("nch = %d, eps=1e-3\n (splitting)",chnkrsp.nch)); |
| 171 | +hold on; plot(r(1,:),r(2,:),'bd'); |
| 172 | +nexttile; plot(chnkr2,'k-x'); title(sprintf("nch = %d, eps=1e-9",chnkr2.nch)); |
| 173 | +hold on; plot(r(1,:),r(2,:),'bd'); |
| 174 | +nexttile; plot(chnkrsp2,'k-x'); title(sprintf("nch = %d, eps=1e-9\n (splitting)",chnkrsp2.nch)); |
| 175 | +hold on; plot(r(1,:),r(2,:),'bd'); |
| 176 | +% END CHUNKERFIT |
| 177 | +saveas(figure(7),"guide_chunkers_chunkerfit.png"); |
0 commit comments