]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/geometry.h
Make use of the mspmath library
[r2c2.git] / source / libr2c2 / geometry.h
1 #ifndef LIBR2C2_GEOMETRY_H_
2 #define LIBR2C2_GEOMETRY_H_
3
4 #include <cmath>
5 #include <vector>
6 #include <msp/geometry/affinetransformation.h>
7 #include <msp/geometry/angle.h>
8 #include <msp/linal/vector.h>
9
10 namespace R2C2 {
11
12 typedef Msp::LinAl::Vector<float, 3> Vector;
13
14 inline float distance(const Vector &p, const Vector &q)
15 { return (p-q).norm(); }
16
17 typedef Msp::Geometry::Angle<float> Angle;
18
19 typedef Msp::Geometry::AffineTransformation<float, 3> Transform;
20
21 inline Vector rotated_vector(const Vector &v, const Angle &a)
22 { return Transform::rotation(a, Vector(0, 0, 1)).transform(v); }
23
24 inline Vector vector_at_angle(const Angle &a)
25 { return rotated_vector(Vector(1, 0, 0), a); }
26
27 struct TrackPoint
28 {
29         Vector pos;
30         Angle dir;
31         float grade;
32
33         TrackPoint(): grade(0) { }
34 };
35
36 } // namespace R2C2
37
38 #endif