Game Development Reference
In-Depth Information
e32 *= s;
e33 *= s;
return *this;
}
The following relation applies for scalar multiplication (and division):
s( M N ) = (s M ) N = M (s N )
Scalar Division: The /= Operator
This operator simply divides each element by the scalar s :
inline Matrix3x3& Matrix3x3::operator/=(float s)
{
e11 /= s;
e12 /= s;
e13 /= s;
e21 /= s;
e22 /= s;
e23 /= s;
e31 /= s;
e32 /= s;
e33 /= s;
return *this;
}
Matrix Functions and Operators
The functions and overloaded operators that follow are useful when you are performing
operations with two matrices, or with a matrix and a scalar, or a matrix and a vector.
Here, the matrices are assumed to be of the type Matrix3x3 , and vectors of the type
Vector , as discussed in Appendix A .
Matrix Addition: The + Operator
This operator adds the two matrices together on an element-by-element basis:
inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2)
{
return Matrix3x3( m1.e11+m2.e11,
m1.e12+m2.e12,
m1.e13+m2.e13,
m1.e21+m2.e21,
m1.e22+m2.e22,
m1.e23+m2.e23,
m1.e31+m2.e31,
m1.e32+m2.e32,
m1.e33+m2.e33);
}
Search Nedrilad ::




Custom Search