ScummVM API documentation
vector.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BAGEL_HODJNPODJ_LIBS_VECTOR_H
23 #define BAGEL_HODJNPODJ_LIBS_VECTOR_H
24 
25 #include "bagel/boflib/stdinc.h"
26 
27 namespace Bagel {
28 namespace HodjNPodj {
29 
30 #define PI (double)3.141592653
31 #define RADCNVT ((double)180/PI) // PI is 180 degrees
32 
33 #define Deg2Rad(d) (d/RADCNVT) // converts degrees to radians
34 #define Rad2Deg(r) (r*RADCNVT) // converts radians to degrees
35 
36 typedef Bagel::Vector VECTOR;
37 
38 class CVector : public VECTOR {
39 public:
40  CVector();
41  CVector(const VECTOR &src);
42  CVector(double xx, double yy, double zz = 0);
43 
44  // vector operations
45  void Unitize();
46  void Normalize();
47  void SetVector(double xx, double yy, double zz = 0);
48  double DotProduct(const VECTOR &rhs) const;
49  void Rotate(double angle);
50  void Reflect(const VECTOR &rhs);
51  double AngleBetween(const VECTOR &rhs);
52  double RealAngle(const VECTOR &rhs);
53  double Length() const;
54 
55  // Generic operations
56  CVector operator +(const VECTOR &rhs) const;
57  CVector operator +(double) const;
58  CVector operator -(const VECTOR &rhs) const;
59  CVector operator -(double) const;
60  CVector operator *(double) const;
61  CVector operator /(double) const;
62  void operator +=(const VECTOR &rhs);
63  void operator -=(const VECTOR &rhs);
64  void operator *=(double);
65  void operator /=(double);
66  bool operator ==(const VECTOR &rhs) const;
67 
68 protected:
69 
70 private:
71 };
72 
73 // misc Vector add-ons
74 extern double distanceBetweenPoints(const VECTOR &v1, const VECTOR &v2);
75 
76 } // namespace HodjNPodj
77 } // namespace Bagel
78 
79 #endif
Definition: stdinc.h:52
Definition: afxwin.h:27