+ vector<Endpoint> part_eps;
+ i->collect_endpoints(part_eps);
+ for(unsigned j=0; j<part_eps.size(); ++j)
+ {
+ float dx = part_eps[j].pos.x-x;
+ float dy = part_eps[j].pos.y-y;
+ if(dx*dx+dy*dy<1e-6)
+ {
+ float plen = i->length;
+ if(i->radius)
+ plen *= abs(i->radius);
+ if(d<plen)
+ {
+ z += d*slope_norm;
+ if(j==1)
+ d = plen-d;
+ Point p = i->get_point(d);
+ float c = cos(rot);
+ float s = sin(rot);
+ return Point(pos.x+c*p.x-s*p.y, pos.y+c*p.y+s*p.x, pos.z+z);
+ }
+ else if(part_eps.size()>1)
+ {
+ d -= plen;
+ x = part_eps[1-j].pos.x;
+ y = part_eps[1-j].pos.y;
+ z += plen*slope_norm;
+ last_part = &*i;
+ i = parts.begin();
+ break;
+ }
+ else
+ return pos;
+ }
+ }
+ }
+
+ if(!last_part)
+ throw Exception("Internal error (Endpoint does not match any part)");
+ else
+ return pos;
+ }