[5809313] | 1 | // |
---|
| 2 | // vector3.h |
---|
| 3 | // |
---|
| 4 | // C++ class for 3-element vectors |
---|
| 5 | // |
---|
| 6 | // Copyright (C) 2000-2001, Mark R. Shinwell. |
---|
| 7 | // |
---|
| 8 | // This program is free software; you can redistribute it and/or modify |
---|
| 9 | // it under the terms of the GNU General Public License as published by |
---|
| 10 | // the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | // (at your option) any later version. |
---|
| 12 | // |
---|
| 13 | // This program is distributed in the hope that it will be useful, |
---|
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | // GNU General Public License for more details. |
---|
| 17 | // |
---|
| 18 | // You should have received a copy of the GNU General Public License |
---|
| 19 | // along with this program; if not, write to the Free Software |
---|
| 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 21 | // |
---|
| 22 | |
---|
| 23 | #ifndef Vector3_h |
---|
| 24 | #define Vector3_h |
---|
| 25 | |
---|
| 26 | class Vector3 { |
---|
| 27 | double x; |
---|
| 28 | double y; |
---|
| 29 | double z; |
---|
| 30 | |
---|
| 31 | public: |
---|
| 32 | Vector3(); |
---|
| 33 | Vector3(double, double, double); |
---|
| 34 | ~Vector3(); |
---|
| 35 | |
---|
| 36 | double getX() { return x; } |
---|
| 37 | double getY() { return y; } |
---|
| 38 | double getZ() { return z; } |
---|
| 39 | |
---|
| 40 | double magnitude(); |
---|
| 41 | void normalise(); |
---|
| 42 | |
---|
| 43 | void set(double, double, double); |
---|
| 44 | |
---|
| 45 | Vector3& operator*=(const double); |
---|
| 46 | Vector3& operator/=(const double); |
---|
| 47 | Vector3& operator=(const Vector3&); |
---|
| 48 | |
---|
| 49 | friend Vector3 operator*(const Vector3&, const double); |
---|
| 50 | friend Vector3 operator*(const double, const Vector3&); |
---|
| 51 | friend Vector3 operator*(const Vector3&, const Vector3&); |
---|
| 52 | friend Vector3 operator+(const Vector3&, const Vector3&); |
---|
| 53 | friend double dot(const Vector3&, const Vector3&); |
---|
| 54 | }; |
---|
| 55 | |
---|
| 56 | #endif |
---|