aboutsummaryrefslogtreecommitdiff
path: root/src/linear.c
diff options
context:
space:
mode:
authorjvech <jmvalenciae@unal.edu.co>2022-08-30 11:30:04 -0500
committerjvech <jmvalenciae@unal.edu.co>2022-08-30 11:30:04 -0500
commitab2160bdd347f4cd827835f1687437d25fae94c6 (patch)
tree91e336ee07b71283cb6a25006c34bdd8e1cf1122 /src/linear.c
parent17b5c7278cf51f767ad1f2823b0c92841b5a4918 (diff)
feat: orthographic transformation added
Diffstat (limited to 'src/linear.c')
-rw-r--r--src/linear.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/linear.c b/src/linear.c
index 8bd58e8..062c103 100644
--- a/src/linear.c
+++ b/src/linear.c
@@ -48,6 +48,26 @@ linearPerspective(float FoV, float ratio, float near, float far)
}
Mat4
+linearOrtho(float left, float right, float bottom, float top, float near, float far)
+{
+ Mat4 out = linearMat4Identity(1.0);
+
+ float width = right - left;
+ float height = top - bottom;
+ float depth = far - near;
+
+ out.matrix[0][0] = 2 / (width);
+ out.matrix[0][3] = - (right + left) / width;
+
+ out.matrix[1][1] = 2 / (height);
+ out.matrix[1][3] = - (top + bottom) / height;
+
+ out.matrix[2][2] = -2 / (depth);
+ out.matrix[2][2] = - (far + near) / depth;
+ return out;
+}
+
+Mat4
linearTranslate(float T_x, float T_y, float T_z)
{
Mat4 out = linearMat4Identity(1.0);
Feel free to download, copy and edit any repo