Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1034114 // onePathToIntervalsOfFixedLength

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (6061L/33K).

static PtBuffer onePathToIntervalsOfFixedLength(OnePath path, double segmentLength) {
  if (path == null) null;
  new PtBuffer out;
  
  int iPath = 0, lPath = path.size();
  var it = path.pointIterator();
  Pt p = it.next(), lastPoint = p;
  double carry = 0;
  while true {
    int iPath2 = iPath;
    double len = 0;
    while (it.hasNext() && (iPath2 == iPath
      || (len = p.minus(lastPoint).length()+carry)+.5 < segmentLength)) {
      p = it.next();
      iPath2++;
    }
    
    if (iPath2 == iPath) break;
    
    out.add(p);
    carry = segmentLength-len;
    printVars ifdef onePathToIntervalsOfFixedLength_debug(+segmentLength, +len, +lastPoint, +p, +carry);
    lastPoint = p;
  }
  ret out;
}

Author comment

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: 131 / 218
Version history: 2 change(s)
Referenced in: [show references]