From: Mikko Rasa Date: Fri, 4 Apr 2014 16:59:03 +0000 (+0300) Subject: Fix an error in calculating curved TrackPart points X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ce7c14abaef869dd7dac1df2f00f95e2307dd5d2;p=r2c2.git Fix an error in calculating curved TrackPart points --- diff --git a/source/libr2c2/trackpart.cpp b/source/libr2c2/trackpart.cpp index 9622b28..882a677 100644 --- a/source/libr2c2/trackpart.cpp +++ b/source/libr2c2/trackpart.cpp @@ -44,7 +44,7 @@ OrientedPoint TrackPart::get_point(float d) const if(radius) { Angle a = Angle::from_radians(d/radius); - result.position = transform.transform(Vector(sin(a)*abs(radius), radius-cos(a)*radius, 0)); + result.position = transform.transform(Vector(sin(a)*radius, (1-cos(a))*radius, 0)); result.rotation = dir+a; } else @@ -69,7 +69,7 @@ OrientedPoint TrackPart::get_nearest_point(const Vector &p) const a = min(max(a, Angle::zero()), Angle::from_radians(length)); if(radius<0) a = -a; - result.position = transform.transform(Vector(sin(a)*abs(radius), radius-cos(a)*radius, 0)); + result.position = transform.transform(Vector(sin(a)*radius, (1-cos(a))*radius, 0)); result.rotation = dir+a; } else