Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2012 was 2012, checked in by chris, 21 years ago

orxonox/branches/chris: Improved doxygen compatibility again

File size: 2.4 KB
RevLine 
[1939]1
2#ifndef VECTOR_H
3#define VECTOR_H
4
[1954]5#include <math.h>
6#define PI 3.14159265359f
[1939]7
[2012]8//! 3D vector
[2010]9/**
10  Class for 3-dimensional vector calculation
11 
12  Supports all common vector operations (dot, cross, lenght and so on)
13*/
[1939]14class Vector {
15
16  public:
17 
18  float x, y, z;
19
[2012]20  Vector (float x, float y, float z) : x(x), y(y), z(z) {}  //!< assignment constructor
[1939]21  Vector () : x(0), y(0), z(0) {}
22  ~Vector () {}
23
24  Vector operator+ (const Vector& v) const;
25  Vector operator- (const Vector& v) const;
26  float operator* (const Vector& v) const;
27  Vector operator* (float f) const;
28  Vector operator/ (float f) const;
29  float dot (const Vector& v) const;
30  Vector cross (const Vector& v) const;
31  float len() const;
32  void normalize();
33};
34
35float angle_deg (const Vector& v1, const Vector& v2);
36float angle_rad (const Vector& v1, const Vector& v2);
37
[2012]38//! 3D rotation
[2010]39/**
40  Class to handle 3-dimensional rotations
41 
42  Can create a rotation from several inputs, currently stores rotation using a 3x3 Matrix
43*/
[1954]44class Rotation {
45  public:
46 
[2012]47  float m[9]; //< 3x3 Rotation Matrix
[1954]48 
49  Rotation ( const Vector& v);
50  Rotation ( const Vector& axis, float angle);
51  Rotation ( float pitch, float yaw, float roll);
52  Rotation ();
53  ~Rotation () {}
54 
55};
56
57Vector rotate_vector( const Vector& v, const Rotation& r);
58
[2012]59//! 3D line
[2010]60/**
61  Class to store Lines in 3-dimensional space
62
63  Supports line-to-line distance measurements and rotation
64*/
[1954]65class Line
66{
67  public:
68 
[2012]69  Vector r;   //!< Offset
70  Vector a;   //!< Direction
[1954]71 
[2012]72  Line ( Vector r, Vector a) : r(r), a(a) {}  //!< assignment constructor
[1954]73  Line () : r(Vector(0,0,0)), a(Vector (1,1,1)) {}
74  ~Line () {}
75 
76  float distance (const Line& l) const;
77  float distance_point (const Vector& v) const;
78  Vector* footpoints (const Line& l) const;
79  float len () const;
80 
81  void rotate(const Rotation& rot);
82};
83
[2012]84//! 3D plane
[2010]85/**
86  Class to handle planes in 3-dimensional space
[2012]87 
[2010]88  Critical for polygon-based collision detection
89*/
[1954]90class Plane
91{
92  public:
93 
[2012]94  Vector n;   //!< Normal vector
95  float k;    //!< Offset constant
[1954]96 
97  Plane (Vector a, Vector b, Vector c);
98  Plane (Vector norm, Vector p);
[2012]99  Plane (Vector n, float k) : n(n), k(k) {} //!< assignment constructor
[1954]100  Plane () : n(Vector(1,1,1)), k(0) {}
101  ~Plane () {}
102 
103  Vector intersect_line (const Line& l) const;
104  float distance_point (const Vector& p) const;
105  float locate_point (const Vector& p) const;
106};
107
[1939]108#endif
Note: See TracBrowser for help on using the repository browser.