4 // C++ class for 3-element vectors
6 // Copyright (C) 2000-2001, Mark R. Shinwell.
7 // Copyright (C) 2002-2003 Olly Betts
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
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.
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 USA
32 void Vector3::normalise()
34 double mag
= magnitude();
42 double dot(const Vector3
& left
, const Vector3
& right
)
44 return left
.x
*right
.x
+ left
.y
*right
.y
+ left
.z
*right
.z
;
47 Vector3
& Vector3::operator*=(const double f
)
56 Vector3
& Vector3::operator/=(const double f
)
65 Vector3
& Vector3::operator+=(const Vector3
&v
)
74 Vector3
& Vector3::operator-=(const Vector3
&v
)
83 Vector3
operator*(const double f
, const Vector3
& v
)
93 Vector3
operator*(const Vector3
& v1
, const Vector3
& v2
)
98 o
.x
= v1
.y
*v2
.z
- v1
.z
*v2
.y
;
99 o
.y
= v1
.z
*v2
.x
- v1
.x
*v2
.z
;
100 o
.z
= v1
.x
*v2
.y
- v1
.y
*v2
.x
;
105 Vector3
operator+(const Vector3
& v1
, const Vector3
& v2
)
115 Vector3
operator-(const Vector3
& v1
, const Vector3
& v2
)