// last
// check if we could end at the segment before the last one
line.setLine(points.get(points.size() - 3),
points.get(points.size() - 2));
if (target.intersects(line)) {
linepoints.remove(linepoints.size() - 1);
} else {
line.setLine(points.get(points.size() - 2),
points.get(points.size() - 1));
}