From 162a6ce2f2cc5d24a177acf9b3c2ce9a0055e1f5 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Wed, 9 Dec 2020 16:28:21 +0800 Subject: [PATCH] add 2d matrix functions, they are translate/scale/rotate --- inc/hgl/math/Matrix.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/inc/hgl/math/Matrix.h b/inc/hgl/math/Matrix.h index 26ba12a..1f2871f 100644 --- a/inc/hgl/math/Matrix.h +++ b/inc/hgl/math/Matrix.h @@ -84,6 +84,11 @@ namespace hgl return Matrix4f::Translate(x,y,z); } + inline Matrix4f translate(float x,float y) + { + return Matrix4f::Translate(x,y,1.0f); + } + inline Matrix4f scale(const Vector3f &v) { return Matrix4f::Scale(v,Vector3f::zero); @@ -94,6 +99,11 @@ namespace hgl return Matrix4f::Scale(Vector3f(x,y,z),Vector3f::zero); } + inline Matrix4f scale(float x,float y) + { + return Matrix4f::Scale(Vector3f(x,y,1.0f),Vector3f::zero); + } + inline Matrix4f scale(float s) { return Matrix4f::Scale(Vector3f(s,s,s),Vector3f::zero); @@ -108,6 +118,11 @@ namespace hgl { return rotate(angle,Vector3f(x,y,z)); } + + inline Matrix4f rotate(float angle,float x,float y) + { + return rotate(angle,Vector3f(x,y,1.0f)); + } inline Matrix4f rotate(float angle,const Vector4f &axis) {