]> git.tdb.fi Git - r2c2.git/commitdiff
Fix an error in calculating curved TrackPart points
authorMikko Rasa <tdb@tdb.fi>
Fri, 4 Apr 2014 16:59:03 +0000 (19:59 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 4 Apr 2014 16:59:03 +0000 (19:59 +0300)
source/libr2c2/trackpart.cpp

index 9622b28e7c8fd0fd283a6d152c04afbeb5faae68..882a6772c7f6cba1b0e9c269ad8ff6a00e0fc8df 100644 (file)
@@ -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