this.lineSegments = new Segment[0];
} else if (size == 2) {
this.lineSegments = new Segment[1];
final Vector2D p1 = vertices[0];
final Vector2D p2 = vertices[1];
this.lineSegments[0] = new Segment(p1, p2, new Line(p1, p2, tolerance));
} else {
this.lineSegments = new Segment[size];
Vector2D firstPoint = null;
Vector2D lastPoint = null;
int index = 0;
for (Vector2D point : vertices) {
if (lastPoint == null) {
firstPoint = point;
lastPoint = point;
} else {
this.lineSegments[index++] =
new Segment(lastPoint, point, new Line(lastPoint, point, tolerance));
lastPoint = point;
}
}
this.lineSegments[index] =
new Segment(lastPoint, firstPoint, new Line(lastPoint, firstPoint, tolerance));
}
}
return lineSegments;
}