- TrackPoint tp = type.get_nearest_point(local);
- tp.pos = Vector(position.x+tp.pos.x*c-tp.pos.y*s, position.y+tp.pos.y*c+tp.pos.x*s, position.z+tp.pos.z);
- tp.dir += rotation;
- return tp;
+ result.position = Vector(position.x+c*ep.pos.x-s*ep.pos.y, position.y+s*ep.pos.x+c*ep.pos.y, position.z);
+ if(eps.size()==2 && i==1)
+ result.position.z += slope;
+
+ result.rotation = rotation+ep.dir;
+
+ return result;
+}
+
+bool Track::snap(Snap &sn, float limit, SnapType what) const
+{
+ if(Object::snap(sn, limit, what))
+ return true;
+
+ if(what&SNAP_SEGMENT)
+ {
+ Vector local(sn.position.x-position.x, sn.position.y-position.y, sn.position.z-position.z);
+ float c = cos(rotation);
+ float s = sin(rotation);
+ local = Vector(c*local.x+s*local.y, c*local.y-s*local.x, local.z);
+
+ TrackPoint tp = type.get_nearest_point(local);
+ Vector d(local.x-tp.pos.x, local.y-tp.pos.y, local.z-tp.pos.z);
+ if(d.x*d.x+d.y*d.y+d.z*d.z<=limit*limit)
+ {
+ sn.position = Vector(position.x+tp.pos.x*c-tp.pos.y*s, position.y+tp.pos.y*c+tp.pos.x*s, position.z+tp.pos.z);
+ sn.rotation = tp.dir+rotation;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+SnapType Track::get_default_snap_type_to(const Object &other) const
+{
+ if(dynamic_cast<const Track *>(&other))
+ return SNAP_NODE;
+
+ return NO_SNAP;