Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/chris/src/vector.h @ 1982

Last change on this file since 1982 was 1982, checked in by chris, 20 years ago

orxonox/branches/chris: merged trunk into my branch, moved new files into new folder

File size: 1.7 KB
Line 
1
2#ifndef VECTOR_H
3#define VECTOR_H
4
5#include <math.h>
6#define PI 3.14159265359f
7
8class Vector {
9
10  public:
11 
12  float x, y, z;
13
14  Vector (float x, float y, float z) : x(x), y(y), z(z) {}
15  Vector () : x(0), y(0), z(0) {}
16  ~Vector () {}
17
18  Vector operator+ (const Vector& v) const;
19  Vector operator- (const Vector& v) const;
20  float operator* (const Vector& v) const;
21  Vector operator* (float f) const;
22  Vector operator/ (float f) const;
23  float dot (const Vector& v) const;
24  Vector cross (const Vector& v) const;
25  float len() const;
26  void normalize();
27};
28
29float angle_deg (const Vector& v1, const Vector& v2);
30float angle_rad (const Vector& v1, const Vector& v2);
31
32float line_distance (Vector* l1, Vector* l2);
33
34class Rotation {
35  public:
36 
37  float m[9];
38 
39  Rotation ( const Vector& v);
40  Rotation ( const Vector& axis, float angle);
41  Rotation ( float pitch, float yaw, float roll);
42  Rotation ();
43  ~Rotation () {}
44 
45};
46
47Vector rotate_vector( const Vector& v, const Rotation& r);
48
49class Line
50{
51  public:
52 
53  Vector r, a;
54 
55  Line ( Vector r, Vector a) : r(r), a(a) {}
56  Line () : r(Vector(0,0,0)), a(Vector (1,1,1)) {}
57  ~Line () {}
58 
59  float distance (const Line& l) const;
60  float distance_point (const Vector& v) const;
61  Vector* footpoints (const Line& l) const;
62  float len () const;
63 
64  void rotate(const Rotation& rot);
65};
66
67class Plane
68{
69  public:
70 
71  Vector n;
72  float k;
73 
74  Plane (Vector a, Vector b, Vector c);
75  Plane (Vector norm, Vector p);
76  Plane (Vector n, float k) : n(n), k(k) {}
77  Plane () : n(Vector(1,1,1)), k(0) {}
78  ~Plane () {}
79 
80  Vector intersect_line (const Line& l) const;
81  float distance_point (const Vector& p) const;
82  float locate_point (const Vector& p) const;
83};
84
85#endif
Note: See TracBrowser for help on using the repository browser.