Esempio n. 1
0
Matrix2x2 operator*(const Matrix2x2 &lhs, const Matrix2x2 &rhs) {
	Matrix2x2 matrix = Matrix2x2();
	matrix.set(0, 0, lhs.get(0, 0) * rhs.get(0, 0) + lhs.get(0, 1) * rhs.get(1, 0));
	matrix.set(0, 1, lhs.get(0, 0) * rhs.get(0, 1) + lhs.get(0, 1) * rhs.get(1, 1));
	matrix.set(1, 0, lhs.get(1, 0) * rhs.get(0, 0) + lhs.get(1, 1) * rhs.get(1, 0));
	matrix.set(1, 1, lhs.get(1, 0) * rhs.get(0, 1) + lhs.get(1, 1) * rhs.get(1, 1));
	return matrix;
}
Esempio n. 2
0
Vector2 operator*(const Vector2 &lhs, const Matrix2x2 &rhs)
{
	Vector2 product = Vector2();
	double sum;

	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			sum = product.get(i) + rhs.get(i, j) * lhs.get(j);
          	product.set(i, sum);
		}
	}
	return product;
}
Esempio n. 3
0
Vector2 operator*(const Matrix2x2 &lhs, const Vector2 &rhs) {
	return Vector2(lhs.get(0, 0) * rhs.get(0) + lhs.get(0, 1) * rhs.get(1), 
		           lhs.get(1, 0) * rhs.get(0) + lhs.get(1, 1) * rhs.get(1));
}
Esempio n. 4
0
bool operator==(const Matrix2x2 &lhs, const Matrix2x2 &rhs) {
	return lhs.get(0, 0) == rhs.get(0, 0) && lhs.get(0, 1) == rhs.get(0, 1)
		&& lhs.get(1, 0) == rhs.get(1, 0) && lhs.get(1, 1) == rhs.get(1, 1);
}