X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrackpart.cpp;h=8aab4f2e88133b319a2eb3ef7b46cc5b9709370b;hb=437ad8b3b19d2ba396551efa66723366364b1ad3;hp=b12ea7278da28ce984e1ad156fb0cb3064f8e1b7;hpb=bde934f7d5ba07a9442a305192e10024820d13ed;p=r2c2.git diff --git a/source/libr2c2/trackpart.cpp b/source/libr2c2/trackpart.cpp index b12ea72..8aab4f2 100644 --- a/source/libr2c2/trackpart.cpp +++ b/source/libr2c2/trackpart.cpp @@ -37,30 +37,30 @@ float TrackPart::get_length() const return length; } -TrackPoint TrackPart::get_point(float d) const +OrientedPoint TrackPart::get_point(float d) const { - TrackPoint result; + OrientedPoint result; Transform dir_trans = Transform::rotation(dir, Vector(0, 0, 1)); if(radius) { Angle a = Angle::from_radians(d/radius); Vector r = dir_trans.transform(Vector(0, -radius, 0)); - result.pos = pos-r+Transform::rotation(a, Vector(0, 0, 1)).transform(r); - result.dir = dir+a; + result.position = pos-r+Transform::rotation(a, Vector(0, 0, 1)).transform(r); + result.rotation = dir+a; } else { - result.pos = pos+dir_trans.transform(Vector(d, 0, 0)); - result.dir = dir; + result.position = pos+dir_trans.transform(Vector(d, 0, 0)); + result.rotation = dir; } return result; } -TrackPoint TrackPart::get_nearest_point(const Vector &p) const +OrientedPoint TrackPart::get_nearest_point(const Vector &p) const { - TrackPoint tp; + OrientedPoint result; Transform dir_trans = Transform::rotation(dir, Vector(0, 0, 1)); if(radius) { @@ -73,18 +73,18 @@ TrackPoint TrackPart::get_nearest_point(const Vector &p) const a = min(max(a, Angle::zero()), Angle::from_radians(length)); if(radius<0) a = -a; - tp.pos = pos-r+Transform::rotation(a, Vector(0, 0, 1)).transform(r); - tp.dir = dir+a; + result.position = pos-r+Transform::rotation(a, Vector(0, 0, 1)).transform(r); + result.rotation = dir+a; } else { Vector v = p-pos; Vector dir_vec = dir_trans.transform(Vector(1, 0, 0)); float d = min(max(dot(dir_vec, v), 0.0f), length); - tp.pos = pos+dir_vec*d; - tp.dir = dir; + result.position = pos+dir_vec*d; + result.rotation = dir; } - return tp; + return result; } void TrackPart::check_link(TrackPart &other) @@ -93,14 +93,14 @@ void TrackPart::check_link(TrackPart &other) unsigned n_other_eps = (other.is_dead_end() ? 1 : 2); for(unsigned i=0; i