- int j = 1;
- while(j < pos)
- {
- double dx = vec[j].x - vec[j-1].x;
- double dy = vec[j].y - vec[j-1].y;
- double d = dx*dx + dy*dy;
- if ((vec[j-1].x == vec[j].x)
- && (vec[j-1].y == vec[j].y))
- {
- // adjacent identical points; remove one
- memcpy(&(vec[j]), &(vec[j + 1]), sizeof(vec[j]) * (pos - j));
- --pos;
- }
- else
- {
- // different
- ++j;
- }
+ if ((vec[t-1].x == vec[t].x) && (vec[t-1].y == vec[t].y)) {
+ // adjacent identical points; remove one
+ memcpy(&(vec[t]), &(vec[t + 1]), sizeof(vec[t]) * (pos - t));
+ pos--;
+ } else {
+ t++;