Math相关头文件移到hgl/math目录

This commit is contained in:
2018-11-30 16:50:08 +08:00
parent d5450325ba
commit 4fb13ced34
6 changed files with 102 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
#ifndef HGL_ALGORITHM_VECTOR_MATH_INCLUDE
#ifndef HGL_ALGORITHM_VECTOR_MATH_INCLUDE
#define HGL_ALGORITHM_VECTOR_MATH_INCLUDE
#include<hgl/type/DataType.h>
@@ -6,11 +6,11 @@
//注GLM/CML(OpenGLMode)是列矩阵,计算坐标matrix*pos
// 而MGL是行矩阵需要反过来pos*matrix
#include<hgl/algorithm/MathMGL.h> // Game Math and Geometry Library
#include<hgl/math/MathMGL.h> // Game Math and Geometry Library
namespace hgl
{
namespace algorithm
namespace math
{
double Lsin(int angle); ///<低精度sin计算,注意传入的参数为角度而非弧度
double Lcos(int angle); ///<低精度cos计算,注意传入的参数为角度而非弧度
@@ -150,6 +150,6 @@ namespace hgl
result.x = center.x + ((source.x - center.x)*ac - (source.y - center.y)*as);
result.y = center.y + ((source.x - center.x)*as + (source.y - center.y)*ac);
}
}//namespace algorithm
}//namespace math
}//namespace hgl
#endif//HGL_ALGORITHM_VECTOR_MATH_INCLUDE

View File

@@ -1,4 +1,4 @@
#ifndef HGL_ALGORITHM_VECTOR_MATH_MGL_INCLUDE
#ifndef HGL_ALGORITHM_VECTOR_MATH_MGL_INCLUDE
#define HGL_ALGORITHM_VECTOR_MATH_MGL_INCLUDE
#ifdef _MSC_VER
@@ -119,11 +119,21 @@ namespace hgl
return m.Inverted();
}
inline Matrix4f ortho2d(float width,float height,float znear=0,float zfar=1)
/**
* 2D正角视图矩阵
* @param width
* @param height
* @param top_to_bottom (y轴为0)
* @param znear z值
* @param zfar z值
*/
inline Matrix4f ortho2d(float width,float height,bool top_to_bottom=false,float znear=0,float zfar=1)
{
//MathGeoLib生成的2D正交矩阵中心是0,0所以需要偏移
return Matrix4f::OpenGLOrthoProjRH(znear,zfar,width,height)*Matrix4f::Scale(1,-1,1)*Matrix4f::Translate(-(width/2.0f),-(height/2.0f),0);
return Matrix4f::OpenGLOrthoProjRH(znear,zfar,width,height)
*Matrix4f::Scale(1,top_to_bottom?-1:1,1)
*Matrix4f::Translate(-(width/2.0f),-(height/2.0f),0);
}
inline Matrix4f translate(const Vector3f &v)

View File

@@ -3,7 +3,7 @@
#include<hgl/type/BaseString.h>
#include<hgl/type/Map.h>
#include<hgl/algorithm/Math.h>
#include<hgl/math/Math.h>
// #include<hgl/graph/UBO.h>
// #include<hgl/graph/SSBO.h>
namespace hgl