Add homogeneous scale transformation

Add function to generate homogeneous 3 dimensional scale transformation
matrices.
This commit is contained in:
Lawrence 2019-12-25 14:45:47 -08:00
parent 1c6a635497
commit 253da17bc7
2 changed files with 26 additions and 0 deletions

View File

@ -147,6 +147,23 @@ Matrix<T> rotationMatrix(double radians, Axis axis)
return matrix;
}
template <typename T>
Matrix<T> scaleMatrix(T x, T y, T z)
{
Matrix<T> matrix;
for (int i = 0; i < 4; i++) {
matrix[i].fill(0);
}
matrix[0][0] = x;
matrix[1][1] = y;
matrix[2][2] = z;
matrix[3][3] = 1;
return matrix;
}
template <typename T>
Matrix<T> translationMatrix(T x, T y, T z)
{

View File

@ -53,6 +53,15 @@ Matrix<T> projectionMatrix(T location, Axis normal);
template <typename T>
Matrix<T> rotationMatrix(T radians, Axis axis);
/**
* Creates a 3 dimensional transformation matrix for scaling.
* @param x Scale in x-direction
* @param y Scale in y-direction
* @param z Scale in z-direction
*/
template <typename T>
Matrix<T> scaleMatrix(T x, T y, T z);
/**
* Creates a 3 dimensional transformation matrix for translation.
* @param x Translation in the the x-direction.