Initial revision
[lsystem3d.git] / src / vector.h
1 // Copyright (C) 2006 Erik Dahlberg
2 //
3 // This file is part of LSystem3d.
4 //
5 // LSystem3D is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // LSystem3D is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with LSystem3D; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20
21
22 #ifndef VECTOR_H
23 #define VECTOR_H
24
25 #include "coordinate.h"
26
27
28
29 /**
30 * 3d vector
31 */
32 class Vector : public Coordinate
33 {
34 public:
35 /**
36 * Constructor
37 * @param x the x-coordinate
38 * @param y the y-coordinate
39 * @param z the z-coordinate
40 */
41 Vector(double x = 0.0, double y = 1.0, double z = 0.0);
42
43 /**
44 * Destructor
45 */
46 ~Vector();
47
48 /**
49 * Rotate around another vector
50 * @param angle rotation angle
51 * @param vector arbitrary vector to rotate around
52 */
53 void rotate(double angle, Vector vector);
54
55 /**
56 * Normalize vector
57 */
58 void normalize();
59
60 /**
61 * Get scalar product of the vectors
62 * @param vector arbitrary vector
63 * @return the scalar product
64 */
65 double getScalarProduct(Vector vector);
66
67 /**
68 * Get cross product of the vectors
69 * @param vector arbitrary vector
70 * @return the cross product
71 */
72 Vector getCrossProduct(Vector vector);
73
74 /**
75 * Get angle between the vectors
76 * @param vector the second (normalized) vector
77 * @return the angle, in degrees
78 */
79 double getAngle(Vector vector);
80 };
81
82
83
84 #endif