Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-21 19:06:15 +0000
committerStijn Buys <ingar@osirion.org>2008-02-21 19:06:15 +0000
commit8aa04fc836116a58f8ffd1e0c3539b9ea8a94ddf (patch)
treebb933edb3919ed67d05b098a6b97a73f01746762 /src/math/vector3f.cc
parent41ad1e4c9e2a70d0a8811f4b035f0d3018045e61 (diff)
dedicated server, entity transfer
Diffstat (limited to 'src/math/vector3f.cc')
-rw-r--r--src/math/vector3f.cc31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/math/vector3f.cc b/src/math/vector3f.cc
index 277795b..ddf46af 100644
--- a/src/math/vector3f.cc
+++ b/src/math/vector3f.cc
@@ -106,14 +106,6 @@ Vector3f Vector3f::operator+(const Vector3f& other) const
return (r);
}
-float Vector3f::operator*(const Vector3f& other) const
-{
- float r = 0;
- for (int i=0; i < 3; i++)
- r += coord[i] * other.coord[i];
- return (r);
-}
-
bool Vector3f::operator==(const Vector3f& other) const
{
for (int i=0; i < 3; i++)
@@ -144,7 +136,21 @@ void Vector3f::normalize()
(*this) /= this->length();
}
-std::ostream &operator<<(std::ostream & os, const Vector3f & vector)
+Vector3f operator*(float scalar, const Vector3f& vector)
+{
+ return vector * scalar;
+}
+
+Vector3f crossproduct(const Vector3f& first, const Vector3f& second)
+{
+ float x = first[1]*second[2] - first[2]*second[1];
+ float y = first[2]*second[0] - first[0]*second[2];
+ float z = first[0]*second[1] - first[1]*second[0];
+
+ return(Vector3f(x,y,z));
+}
+
+std::ostream &operator<<(std::ostream & os, Vector3f const & vector)
{
os << vector[0] << " " << vector[1] << " " << vector[2];
return os;
@@ -157,9 +163,12 @@ std::istream &operator>>(std::istream & is, Vector3f & vector)
return is;
}
-Vector3f operator*(float scalar, const Vector3f& vector)
+float dotproduct(const Vector3f& first, const Vector3f& second)
{
- return vector * scalar;
+ float r = 0;
+ for (int i=0; i < 3; i++)
+ r += first[i] * second[i];
+ return (r);
}
} // namespace math