コード例 #1
0
void Matrix4::operator *= (Matrix4 &other) {
	Matrix4 temp;
	values[0][0] = getRow1().dotProduct(other.getColumn1());
	values[1][0] = getRow1().dotProduct(other.getColumn2());
	values[2][0] = getRow1().dotProduct(other.getColumn3());
	values[3][0] = getRow1().dotProduct(other.getColumn4());

	values[0][1] = getRow2().dotProduct(other.getColumn1());
	values[1][1] = getRow2().dotProduct(other.getColumn2());
	values[2][1] = getRow2().dotProduct(other.getColumn3());
	values[3][1] = getRow2().dotProduct(other.getColumn4());

	values[0][2] = getRow3().dotProduct(other.getColumn1());
	values[1][2] = getRow3().dotProduct(other.getColumn2());
	values[2][2] = getRow3().dotProduct(other.getColumn3());
	values[3][2] = getRow3().dotProduct(other.getColumn4());

	values[0][3] = getRow4().dotProduct(other.getColumn1());
	values[1][3] = getRow4().dotProduct(other.getColumn2());
	values[2][3] = getRow4().dotProduct(other.getColumn3());
	values[3][3] = getRow4().dotProduct(other.getColumn4());
	for (int i = 0; i <= 3; i++) {
		for (int j = 0; j <= 3; j++) {
			values[i][j] = temp.values[i][j];
		}
	}
}
コード例 #2
0
Matrix4 Matrix4::operator * (Matrix4 &other) {
	Matrix4 temp;
	temp.values[0][0] = getRow1().dotProduct(other.getColumn1());
	temp.values[1][0] = getRow1().dotProduct(other.getColumn2());
	temp.values[2][0] = getRow1().dotProduct(other.getColumn3());
	temp.values[3][0] = getRow1().dotProduct(other.getColumn4());

	temp.values[0][1] = getRow2().dotProduct(other.getColumn1());
	temp.values[1][1] = getRow2().dotProduct(other.getColumn2());
	temp.values[2][1] = getRow2().dotProduct(other.getColumn3());
	temp.values[3][1] = getRow2().dotProduct(other.getColumn4());

	temp.values[0][2] = getRow3().dotProduct(other.getColumn1());
	temp.values[1][2] = getRow3().dotProduct(other.getColumn2());
	temp.values[2][2] = getRow3().dotProduct(other.getColumn3());
	temp.values[3][2] = getRow3().dotProduct(other.getColumn4());

	temp.values[0][3] = getRow4().dotProduct(other.getColumn1());
	temp.values[1][3] = getRow4().dotProduct(other.getColumn2());
	temp.values[2][3] = getRow4().dotProduct(other.getColumn3());
	temp.values[3][3] = getRow4().dotProduct(other.getColumn4());
	return temp;
}