X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fgeometry.h;h=dc29212735fa806b8c9fb79668c20bb5a735a19c;hb=refs%2Fheads%2Fmaster;hp=8519499ef581c5d6a67ea656d1dbe1fee32aecb1;hpb=f8a7788cee0261babfc4c804a58515aad6dfbc3d;p=r2c2.git diff --git a/source/libr2c2/geometry.h b/source/libr2c2/geometry.h index 8519499..dc29212 100644 --- a/source/libr2c2/geometry.h +++ b/source/libr2c2/geometry.h @@ -1,37 +1,40 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef LIBR2C2_GEOMETRY_H_ #define LIBR2C2_GEOMETRY_H_ #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; - TrackPoint(): dir(0), grade(0) { } +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); } + +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