for (int i = size() - 1; i >= 0; i--) {
if (i == 0) // is first
{
SketchPoint p1 = get(i);
SketchPoint p2 = get(i + 1);
Vec2D tangent = p2.sub(p1);
Vec2D q1 = p1.add(tangent.scale(scale));
p1.controlPoint1 = p1;
p1.controlPoint2 = q1;
} else if (i == size() - 1) //last
{
SketchPoint p0 = get(i - 1);
SketchPoint p1 = get(i);
Vec2D tangent = p1.sub(p0);
Vec2D q0 = p1.sub(tangent.scale(scale));
p1.controlPoint1 = q0;
p1.controlPoint2 = p1.copy();
} else {
SketchPoint p0, p1, p2;
p0 = get(i + 1);
p1 = get(i);
p2 = get(i - 1);
Vec2D tangent = (p2.sub(p0)).normalize();
Vec2D q0 = p1.sub(tangent.scale(scale).scale(
p1.sub(p0).magnitude()));
Vec2D q1 = p1.add(tangent.scale(scale).scale(
p2.sub(p1).magnitude()));
p1.controlPoint2 = q0;
p1.controlPoint1 = q1;
}
}
} else {
for (int i = size() - 1; i >= 0; i--) {
SketchPoint p0, p1, p2;
if (i > 0)
p0 = get(i - 1);
else
p0 = get(size() - 1);
p1 = get(i);
if (i < size() - 1)
p2 = get(i + 1);
else
p2 = get(0);
Vec2D tangent = (p2.sub(p0)).normalize();
Vec2D q0 = p1.sub(tangent.scale(scale).scale(
p1.sub(p0).magnitude()));
Vec2D q1 = p1.add(tangent.scale(scale).scale(
p2.sub(p1).magnitude()));
p1.controlPoint1 = q0;
p1.controlPoint2 = q1;
}