added PrimaryMathematics.h
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#ifndef HGL_ALGORITHM_MATH_INCLUDE
|
#ifndef HGL_ALGORITHM_MATH_INCLUDE
|
||||||
#define HGL_ALGORITHM_MATH_INCLUDE
|
#define HGL_ALGORITHM_MATH_INCLUDE
|
||||||
|
|
||||||
|
#include<hgl/math/PrimaryMathematics.h>
|
||||||
#include<hgl/math/FastTriangle.h>
|
#include<hgl/math/FastTriangle.h>
|
||||||
#include<hgl/math/Vector.h> // Game Math and Geometry Library
|
#include<hgl/math/Vector.h> // Game Math and Geometry Library
|
||||||
#include<hgl/math/Matrix.h>
|
#include<hgl/math/Matrix.h>
|
||||||
|
39
inc/hgl/math/PrimaryMathematics.h
Normal file
39
inc/hgl/math/PrimaryMathematics.h
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef HGL_Primary_Mathematics_INCLUDE
|
||||||
|
#define HGL_Primary_Mathematics_INCLUDE
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
const T sum(const T *data,const int count)
|
||||||
|
{
|
||||||
|
T result=0;
|
||||||
|
|
||||||
|
for(int i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
result+=*data;
|
||||||
|
++data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>
|
||||||
|
*/
|
||||||
|
template<typename R,typename T>
|
||||||
|
const R sum(const T *data,const int count)
|
||||||
|
{
|
||||||
|
R result=0;
|
||||||
|
|
||||||
|
for(int i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
result+=*data;
|
||||||
|
++data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_Primary_Mathematics_INCLUDE
|
Reference in New Issue
Block a user