X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fgeometry.h;h=dc29212735fa806b8c9fb79668c20bb5a735a19c;hb=abed4a255060d5a233ec0ac2dd60af9132e29201;hp=67c541211fcd93c7655318dc33e6953e6e85fb28;hpb=d15ac13f2e170f155b4bbd124df48400c339b644;p=r2c2.git diff --git a/source/libr2c2/geometry.h b/source/libr2c2/geometry.h index 67c5412..dc29212 100644 --- a/source/libr2c2/geometry.h +++ b/source/libr2c2/geometry.h @@ -3,28 +3,38 @@ #include #include +#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(); } -struct TrackPoint -{ - Vector pos; - float dir; - float grade; +typedef Msp::Geometry::Angle Angle; + +typedef Msp::Geometry::AffineTransformation Transform; - TrackPoint(): dir(0), grade(0) { } +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); } + +typedef Msp::Geometry::Shape Shape; +typedef Msp::Geometry::Ray Ray; +typedef Msp::Geometry::BoundingBox BoundingBox; + +struct OrientedPoint +{ + Vector position; + Angle rotation; + Angle tilt; }; } // namespace R2C2