Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/vector3f.cc')
-rw-r--r--src/math/vector3f.cc46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/math/vector3f.cc b/src/math/vector3f.cc
index 1e9fd2b..4594665 100644
--- a/src/math/vector3f.cc
+++ b/src/math/vector3f.cc
@@ -56,35 +56,35 @@ Vector3f & Vector3f::operator=(const Vector3f & other)
Vector3f & Vector3f::operator*=(const float scalar)
{
- for (int i=0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
coord[i] *= scalar;
return (*this);
}
Vector3f & Vector3f::operator/=(const float scalar)
{
- for (int i=0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
coord[i] /= scalar;
return (*this);
}
Vector3f &Vector3f::operator-=(const Vector3f & other)
{
- for (int i=0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
coord[i] -= other[i];
return (*this);
}
Vector3f &Vector3f::operator+=(const Vector3f &other)
{
- for (int i=0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
coord[i] += other[i];
return (*this);
}
bool Vector3f::operator==(const Vector3f& other) const
{
- for (int i=0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
if (coord[i] != other.coord[i])
return (false);
return (true);
@@ -93,17 +93,17 @@ bool Vector3f::operator==(const Vector3f& other) const
float Vector3f::lengthsquared() const
{
float r = 0;
- for (int i=0; i < 3; i++)
- r += coord[i]*coord[i];
+ for (int i = 0; i < 3; i++)
+ r += coord[i] * coord[i];
return ((float) r);
}
float Vector3f::length() const
{
float r = 0;
- for (int i=0; i < 3; i++)
- r += coord[i]*coord[i];
-
+ for (int i = 0; i < 3; i++)
+ r += coord[i] * coord[i];
+
return (sqrtf(r));
}
@@ -125,24 +125,24 @@ std::ostream &operator<<(std::ostream & os, const Vector3f & vector)
std::istream &operator>>(std::istream & is, Vector3f & vector)
{
- for (int i=0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
is >> vector[i];
return is;
}
-const Vector3f crossproduct(const Vector3f & first, Vector3f const &second)
+const Vector3f crossproduct(const Vector3f & first, const Vector3f &second)
{
- float vx = first[1]*second[2] - first[2]*second[1];
- float vy = first[2]*second[0] - first[0]*second[2];
- float vz = first[0]*second[1] - first[1]*second[0];
-
- return(Vector3f(vx,vy,vz));
+ float vx = first[1] * second[2] - first[2] * second[1];
+ float vy = first[2] * second[0] - first[0] * second[2];
+ float vz = first[0] * second[1] - first[1] * second[0];
+
+ return(Vector3f(vx, vy, vz));
}
float dotproduct(const Vector3f& first, const Vector3f& second)
{
float r = 0;
- for (int i=0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
r += first[i] * second[i];
return (r);
}
@@ -150,17 +150,17 @@ float dotproduct(const Vector3f& first, const Vector3f& second)
float distance(const Vector3f& first, const Vector3f& second)
{
float r = 0;
- for (int i=0; i < 3; i++)
- r += (first[i]-second[i])*(first[i]-second[i]);
-
+ for (int i = 0; i < 3; i++)
+ r += (first[i] - second[i]) * (first[i] - second[i]);
+
return (sqrtf(r));
}
float distancesquared(const Vector3f& first, const Vector3f& second)
{
float r = 0;
- for (int i=0; i < 3; i++)
- r += (first[i]-second[i])*(first[i]-second[i]);
+ for (int i = 0; i < 3; i++)
+ r += (first[i] - second[i]) * (first[i] - second[i]);
return (r);
}