appendChain method
void
appendChain(
- int index1,
- int index2
)
Implementation
void appendChain(int index1, int index2) {
// index1 gets index2 appended to it, and index2 is removed
var chain1 = chains[index1];
var chain2 = chains[index2];
var tail = chain1[chain1.length - 1];
var tail2 = chain1[chain1.length - 2];
var head = chain2[0];
var head2 = chain2[1];
if (Epsilon().pointsCollinear(tail2, tail, head)) {
// tail isn't needed because it's directly between tail2 and head
// tail2 ---tail---> head
//if (buildLog != null) buildLog.chainRemoveTail(index1, tail);
chain1.removeAt(chain1.length - 1);
tail = tail2; // old tail is gone... new tail is what tail2 was
}
if (Epsilon().pointsCollinear(tail, head, head2)) {
// head isn't needed because it's directly between tail and head2
// tail ---head---> head2
// if (buildLog != null) buildLog.chainRemoveHead(index2, head);
chain2.removeAt(0);
}
// if (buildLog != null) buildLog.chainJoin(index1, index2);
chain1.addAll(chain2);
chains.removeAt(index2);
}