X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fgeometry.h;h=09044e35886d6ccf1df13d5d0c5b5d77a0acca0d;hb=7a36d396eded897c421424905b2c938d770df341;hp=67c541211fcd93c7655318dc33e6953e6e85fb28;hpb=14116fc9bbbd118f0be564c4e14ec00bfab26d24;p=r2c2.git diff --git a/source/libr2c2/geometry.h b/source/libr2c2/geometry.h index 67c5412..09044e3 100644 --- a/source/libr2c2/geometry.h +++ b/source/libr2c2/geometry.h @@ -3,28 +3,34 @@ #include #include +#include +#include +#include namespace R2C2 { -struct Vector -{ - float x, y, z; - - Vector(): x(0), y(0), z(0) { } - Vector(float x_, float y_): x(x_), y(y_), z(0) { } - Vector(float x_, float y_, float z_): x(x_), y(y_), z(z_) { } -}; +typedef Msp::LinAl::Vector Vector; inline float distance(const Vector &p, const Vector &q) -{ return sqrt((p.x-q.x)*(p.x-q.x) + (p.y-q.y)*(p.y-q.y) + (p.z-q.z)*(p.z-q.z)); } +{ return (p-q).norm(); } + +typedef Msp::Geometry::Angle Angle; + +typedef Msp::Geometry::AffineTransformation Transform; + +inline Vector rotated_vector(const Vector &v, const Angle &a) +{ return Transform::rotation(a, Vector(0, 0, 1)).transform(v); } + +inline Vector vector_at_angle(const Angle &a) +{ return rotated_vector(Vector(1, 0, 0), a); } struct TrackPoint { Vector pos; - float dir; + Angle dir; float grade; - TrackPoint(): dir(0), grade(0) { } + TrackPoint(): grade(0) { } }; } // namespace R2C2