reworked Vector::reflect() to reflect an INCOMING ray
git-svn-id: svn://anubis/fart/trunk@371 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
15e4aa1dc0
commit
1eee61002e
2 files changed
+7
-7
No files matched your search
+5
-5
@@ -60,9 +60,7 @@ class Vector
|
||||
|
||||
Vector reflect(const Vector & target) const
|
||||
{
|
||||
Vector projected = proj(target);
|
||||
Vector me_to_proj = projected - (*this);
|
||||
return (*this) + me_to_proj * 2.0;
|
||||
return (*this) - target * (2 * dot(target));
|
||||
}
|
||||
|
||||
Vector getPerpendicular() const
|
||||
@@ -102,21 +100,23 @@ class Vector
|
||||
}
|
||||
|
||||
/* Compute the dot-product of two vectors */
|
||||
double operator%(const Vector & v2) const
|
||||
double dot(const Vector & v2) const
|
||||
{
|
||||
return m_array[0] * v2.m_array[0]
|
||||
+ m_array[1] * v2.m_array[1]
|
||||
+ m_array[2] * v2.m_array[2];
|
||||
}
|
||||
double operator%(const Vector & v2) const { return dot(v2); }
|
||||
|
||||
/* Compute the cross-product of two vectors */
|
||||
Vector operator*(const Vector & v2) const
|
||||
Vector cross(const Vector & v2) const
|
||||
{
|
||||
return Vector(
|
||||
m_array[1] * v2.m_array[2] - m_array[2] * v2.m_array[1],
|
||||
m_array[2] * v2.m_array[0] - m_array[0] * v2.m_array[2],
|
||||
m_array[0] * v2.m_array[1] - m_array[1] * v2.m_array[0]);
|
||||
}
|
||||
Vector operator*(const Vector & v2) const { return cross(v2); }
|
||||
|
||||
Vector operator+(const Vector & v2) const
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user