The Gnome Chemistry Utils  0.14.0
vector.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * vector.h
6  *
7  * Copyright (C) 2007-2010 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_VECTOR_H
26 #define GCU_VECTOR_H
27 
28 #include "macros.h"
29 
31 namespace gcu
32 {
33 
39 class Vector
40 {
41 public:
45  Vector ();
53  Vector (double x, double y, double z);
59  Vector (double d[3]);
65  Vector (Vector const &v);
66 
72  Vector operator+ (Vector const &v) const;
78  Vector operator- (Vector const &v) const;
84  Vector operator* (double m) const;
90  Vector operator/ (double d) const;
97  Vector operator*= (double m);
104  Vector operator/= (double d);
110  double operator[] (unsigned i) const;
111 
115  double GetLength () const;
119  Vector CreateOrthogonal () const;
125  Vector Cross (Vector const &v) const;
126 
138 GCU_PROP (double, X)
150 GCU_PROP (double, Y)
162 GCU_PROP (double, Z)
163 };
164 
171 Vector operator* (double f, Vector const& v);
172 
177 class Vector3f
178 {
179 public:
183  Vector3f ();
191  Vector3f (float x, float y, float z);
195  ~Vector3f ();
196 
199  void normalize ();
206  Vector3f &operator= (Vector3f const& other);
212  Vector3f operator- (Vector3f const& other) const;
218  Vector3f operator+ (Vector3f const& other) const;
224  Vector3f operator* (float f) const;
225 
226 private:
238  GCU_PROP (float, x);
250  GCU_PROP (float, y);
262  GCU_PROP (float, z);
263 };
264 
271 Vector3f operator* (float f, Vector3f const& v);
272 
273 } //namespace gcu
274 
275 #endif //GCU_VECTOR_H