Libraryless. Click here for Pure Java version (6061L/33K).
1 | static PtBuffer onePathToIntervalsOfFixedLength(OnePath path, double segmentLength) {
|
2 | if (path == null) null; |
3 | new PtBuffer out; |
4 | |
5 | int iPath = 0, lPath = path.size(); |
6 | var it = path.pointIterator(); |
7 | Pt p = it.next(), lastPoint = p; |
8 | double carry = 0; |
9 | while true {
|
10 | int iPath2 = iPath; |
11 | double len = 0; |
12 | while (it.hasNext() && (iPath2 == iPath |
13 | || (len = p.minus(lastPoint).length()+carry)+.5 < segmentLength)) {
|
14 | p = it.next(); |
15 | iPath2++; |
16 | } |
17 | |
18 | if (iPath2 == iPath) break; |
19 | |
20 | out.add(p); |
21 | carry = segmentLength-len; |
22 | printVars ifdef onePathToIntervalsOfFixedLength_debug(+segmentLength, +len, +lastPoint, +p, +carry); |
23 | lastPoint = p; |
24 | } |
25 | ret out; |
26 | } |
Began life as a copy of #1034112
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1034114 |
| Snippet name: | onePathToIntervalsOfFixedLength |
| Eternal ID of this version: | #1034114/3 |
| Text MD5: | 88fadc5bb009f0478c4d6e20be05bade |
| Transpilation MD5: | 759f66468ea7c309b20b7bdc48659780 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-01-22 18:12:51 |
| Source code size: | 735 bytes / 26 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 360 / 501 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |