示例#1
0
/**
Gets a 3x3 matrix consisting of all cells besides those along the given row or column.
*/
Mat3x3 GetSubmatrix(const Mat4x4& m, int row, int col)
{
	int nextRow = 0;
	int nextColumn = 0;
	Mat3x3 result = Mat3x3::Zero();

	//we will loop through each element of our 4x4;
	//if the current element is valid (neither on the same row as [row] or column as [col])
	//then set Mat3x3(nextRow, nextColumn) and increment nextColumn
	//then increment nextRow
	//the last step might not be necessary
	for (int i = 0; i < MAT4X4_NUM_CELLS; i++)
	{
		//if this row is valid...
		if (i != row)
		{
			//reset nextColumn
			nextColumn = 0;
			for (int j = 0; j < MAT4X4_NUM_CELLS; j++)
			{
				if (j != col)
				{
					result(nextRow, nextColumn) = m.AtCoordinate(i, j);
					nextColumn++;
				}
			}
			//move nextRow down a row
			nextRow++;
		}
	}
	return result;
}
示例#2
0
Mat4x4 Mat4x4::GetTransposed(const Mat4x4& m)
{
	Mat4x4 result = Mat4x4();
	for (int i = 0; i < MAT4X4_NUM_CELLS; ++i)
	{
		int x = i % MAT4X4_WIDTH;
		int y = i / MAT4X4_WIDTH;

		result(y, x) = m.AtCoordinate(x, y);
	}
	return result;
}