]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/geometry.h
8519499ef581c5d6a67ea656d1dbe1fee32aecb1
[r2c2.git] / source / libr2c2 / geometry.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBR2C2_GEOMETRY_H_
9 #define LIBR2C2_GEOMETRY_H_
10
11 #include <cmath>
12 #include <vector>
13
14 namespace R2C2 {
15
16 struct Vector
17 {
18         float x, y, z;
19
20         Vector(): x(0), y(0), z(0) { }
21         Vector(float x_, float y_): x(x_), y(y_), z(0) { }
22         Vector(float x_, float y_, float z_): x(x_), y(y_), z(z_) { }
23 };
24
25 inline float distance(const Vector &p, const Vector &q)
26 { 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)); }
27
28 struct TrackPoint
29 {
30         Vector pos;
31         float dir;
32         float grade;
33
34         TrackPoint(): dir(0), grade(0) { }
35 };
36
37 } // namespace R2C2
38
39 #endif