]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/geometry.h
Eliminate a possible race condition in thread termination
[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/geometry/ray.h>
9 #include <msp/geometry/shape.h>
10 #include <msp/linal/vector.h>
11
12 namespace R2C2 {
13
14 typedef Msp::LinAl::Vector<float, 3> Vector;
15
16 inline float distance(const Vector &p, const Vector &q)
17 { return (p-q).norm(); }
18
19 typedef Msp::Geometry::Angle<float> Angle;
20
21 typedef Msp::Geometry::AffineTransformation<float, 3> Transform;
22
23 inline Vector rotated_vector(const Vector &v, const Angle &a)
24 { return Transform::rotation(a, Vector(0, 0, 1)).transform(v); }
25
26 inline Vector vector_at_angle(const Angle &a)
27 { return rotated_vector(Vector(1, 0, 0), a); }
28
29 typedef Msp::Geometry::Shape<float, 3> Shape;
30 typedef Msp::Geometry::Ray<float, 3> Ray;
31 typedef Msp::Geometry::BoundingBox<float, 3> BoundingBox;
32
33 struct OrientedPoint
34 {
35         Vector position;
36         Angle rotation;
37         Angle tilt;
38 };
39
40 } // namespace R2C2
41
42 #endif