added operator%() to util/Matrix
git-svn-id: svn://anubis/fart/trunk@30 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
0044dbb544
commit
2deee25004
@ -214,10 +214,11 @@ Matrix operator*(const Matrix & m1, const Matrix & m2)
|
||||
return res;
|
||||
}
|
||||
|
||||
/* transform a point */
|
||||
Vector operator*(const Matrix & m, const Vector & v)
|
||||
{
|
||||
Vector res;
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
res[i] = m[i][0] * v[0]
|
||||
+ m[i][1] * v[1]
|
||||
@ -227,6 +228,19 @@ Vector operator*(const Matrix & m, const Vector & v)
|
||||
return res;
|
||||
}
|
||||
|
||||
/* transform a direction */
|
||||
Vector operator%(const Matrix & m, const Vector & v)
|
||||
{
|
||||
Vector res;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
res[i] = m[i][0] * v[0]
|
||||
+ m[i][1] * v[1]
|
||||
+ m[i][2] * v[2];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool operator==(const Matrix & m1, const Matrix & m2)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
@ -26,7 +26,8 @@ class Matrix
|
||||
};
|
||||
|
||||
Matrix operator*(const Matrix & m1, const Matrix & m2);
|
||||
Vector operator*(const Matrix & m, const Vector & v);
|
||||
Vector operator*(const Matrix & m, const Vector & v); /* transform point */
|
||||
Vector operator%(const Matrix & m, const Vector & v); /* transform direction */
|
||||
bool operator==(const Matrix & m1, const Matrix & m2);
|
||||
std::ostream & operator<<(std::ostream & out, const Matrix & m);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user