- float a=d/radius;
- float c=cos(a);
- float s=sin(a);
- float rx=radius*sin(dir);
- float ry=-radius*cos(dir);
- return Point(pos.x+c*rx-s*ry-rx, pos.y+c*ry+s*rx-ry);
+ TrackPoint p1 = get_point(i ? get_length() : 0);
+ for(unsigned j=0; j<n_other_eps; ++j)
+ {
+ TrackPoint p2 = other.get_point(j ? other.get_length() : 0);
+
+ float dx = p2.pos.x-p1.pos.x;
+ float dy = p2.pos.y-p1.pos.y;
+
+ float da = p2.dir-p1.dir+M_PI*((i+j+1)%2);
+ while(da>M_PI)
+ da -= M_PI*2;
+ while(da<-M_PI)
+ da += M_PI*2;
+
+ if(dx*dx+dy*dy<1e-6 && da>=-0.01 && da<=0.01)
+ {
+ links[i] = &other;
+ other.links[j] = this;
+ return;
+ }
+ }