From 8e733a241536efcaff8cbff66c8a3a4f1255ed86 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 7 Jul 2025 01:24:46 +0800 Subject: [PATCH] =?UTF-8?q?Rotate=E9=87=8D=E5=91=BD=E5=90=8D=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E5=A2=9E=E5=8A=A0AxisXRotate/AxisYRotate/AxisZRotate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/math/Matrix.h | 20 ++++++++++++-------- inc/hgl/math/Transform.h | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/inc/hgl/math/Matrix.h b/inc/hgl/math/Matrix.h index 178ca06..627718a 100644 --- a/inc/hgl/math/Matrix.h +++ b/inc/hgl/math/Matrix.h @@ -147,29 +147,33 @@ namespace hgl return glm::scale(Matrix4f(1.0f),Vector3f(s,s,s)); } - inline Matrix4f rotate(float rad,const Vector3f &axis) + inline Matrix4f AxisXRotate(float rad){return glm::rotate(Matrix4f(1.0f),rad,AxisVector::X);} + inline Matrix4f AxisYRotate(float rad){return glm::rotate(Matrix4f(1.0f),rad,AxisVector::Y);} + inline Matrix4f AxisZRotate(float rad){return glm::rotate(Matrix4f(1.0f),rad,AxisVector::Z);} + + inline Matrix4f AxisRotate(float rad,const Vector3f &axis) { return glm::rotate(Matrix4f(1.0f),rad,axis); } - inline Matrix4f rotate(float rad,float x,float y,float z) + inline Matrix4f AxisRotate(float rad,float x,float y,float z) { return glm::rotate(Matrix4f(1.0f),rad,Vector3f(x,y,z)); } - inline Matrix4f rotate(float rad,float x,float y) + inline Matrix4f AxisRotate(float rad,float x,float y) { - return rotate(rad,x,y,1.0f); + return AxisRotate(rad,x,y,1.0f); } - inline Matrix4f rotate(float rad,const Vector4f &axis) + inline Matrix4f AxisRotate(float rad,const Vector4f &axis) { - return rotate(rad,Vector3f(axis.x,axis.y,axis.z)); + return AxisRotate(rad,Vector3f(axis.x,axis.y,axis.z)); } - inline Vector3f rotate(const Vector3f &v3f,float rad,const Vector3f &axis) + inline Vector3f AxisRotate(const Vector3f &v3f,float rad,const Vector3f &axis) { - Vector4f result = rotate(rad, axis)*Vector4f(v3f, 1.0f); + Vector4f result = AxisRotate(rad, axis)*Vector4f(v3f, 1.0f); return Vector3f(result.x,result.y,result.z); } diff --git a/inc/hgl/math/Transform.h b/inc/hgl/math/Transform.h index 5fa6a08..a6b2520 100644 --- a/inc/hgl/math/Transform.h +++ b/inc/hgl/math/Transform.h @@ -215,7 +215,7 @@ namespace hgl void MakeNewestData(Matrix4f &mat) override { - mat=rotate(angle,axis); + mat=AxisRotate(angle,axis); } public: