added mult() and div() to Vector
git-svn-id: svn://anubis/fart/trunk@277 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
9546c8dde4
commit
d0fe38566c
@ -86,10 +86,22 @@ Vector Vector::getPerpendicular() const
|
||||
return p;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, const Vector & v)
|
||||
Vector Vector::mult(const Vector & v2) const
|
||||
{
|
||||
out << "[" << v[0] << ", " << v[1] << ", " << v[2] << "]";
|
||||
return out;
|
||||
Vector result;
|
||||
result[0] = m_array[0] * v2.m_array[0];
|
||||
result[1] = m_array[1] * v2.m_array[1];
|
||||
result[2] = m_array[2] * v2.m_array[2];
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector Vector::div(const Vector & v2) const
|
||||
{
|
||||
Vector result;
|
||||
result[0] = m_array[0] / v2.m_array[0];
|
||||
result[1] = m_array[1] / v2.m_array[1];
|
||||
result[2] = m_array[2] / v2.m_array[2];
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector Vector::operator-() const
|
||||
@ -170,3 +182,9 @@ Vector & Vector::operator-=(const Vector & v2)
|
||||
m_array[2] -= v2.m_array[2];
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & out, const Vector & v)
|
||||
{
|
||||
out << "[" << v[0] << ", " << v[1] << ", " << v[2] << "]";
|
||||
return out;
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ class Vector
|
||||
Vector reflect(const Vector & target) const;
|
||||
Vector getPerpendicular() const;
|
||||
|
||||
Vector mult(const Vector & v2) const;
|
||||
Vector div(const Vector & v2) const;
|
||||
Vector operator-() const;
|
||||
double operator%(const Vector & v2) const;
|
||||
Vector operator*(const Vector & v2) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user