1 ///////////////////////////////////////////////////////////////////////////
5 // This file is part of starlight.
7 // starlight 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.
12 // starlight 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.
17 // You should have received a copy of the GNU General Public License
18 // along with starlight. If not, see <http://www.gnu.org/licenses/>.
20 ///////////////////////////////////////////////////////////////////////////
22 // File and Version Information:
23 // $Rev:: 28 $: revision of last commit
24 // $Author:: bgrube $: author of last commit
25 // $Date:: 2010-12-10 19:30:01 +0100 #$: date of last commit
31 ///////////////////////////////////////////////////////////////////////////
47 vector3(double x, double y, double z);
50 const double* GetVector() const { return _vec; }
52 void SetVector(double x, double y, double z);
53 void SetVector(double *vec);
55 vector3& operator =(const vector3& vec)
58 for (unsigned int i = 0; i < 3; ++i)
59 _vec[i] = vec._vec[i];
63 vector3& operator +=(const vector3& vec)
65 for (unsigned int i = 0; i < 3; ++i)
66 _vec[i] += vec._vec[i];
69 vector3& operator -=(const vector3& vec)
71 for (unsigned int i = 0; i < 3; ++i)
72 _vec[i] -= vec._vec[i];
76 double X() const { return _vec[0]; }
77 double Y() const { return _vec[1]; }
78 double Z() const { return _vec[2]; }
80 double Mag2() const { return _vec[0] * _vec[0] + _vec[1] * _vec[1] + _vec[2] * _vec[2]; }
81 double Mag () const { return sqrt(Mag2()); }
83 friend std::ostream& operator << (std::ostream& out,
86 out << "(" << vec.X() << ", " << vec.Y() << ", " << vec.Z() << ")";