diff --git a/rtengine/homogeneouscoordinates.cc b/rtengine/homogeneouscoordinates.cc index f134abc53..85b189b9f 100644 --- a/rtengine/homogeneouscoordinates.cc +++ b/rtengine/homogeneouscoordinates.cc @@ -147,6 +147,23 @@ Matrix rotationMatrix(double radians, Axis axis) return matrix; } +template +Matrix scaleMatrix(T x, T y, T z) +{ + Matrix 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 Matrix translationMatrix(T x, T y, T z) { diff --git a/rtengine/homogeneouscoordinates.h b/rtengine/homogeneouscoordinates.h index c24b73f05..7c5924d1e 100644 --- a/rtengine/homogeneouscoordinates.h +++ b/rtengine/homogeneouscoordinates.h @@ -53,6 +53,15 @@ Matrix projectionMatrix(T location, Axis normal); template Matrix 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 +Matrix scaleMatrix(T x, T y, T z); + /** * Creates a 3 dimensional transformation matrix for translation. * @param x Translation in the the x-direction.