diff options
Diffstat (limited to 'source/modules/asura-utils/Math')
-rw-r--r-- | source/modules/asura-utils/Math/Matrix44.h | 120 | ||||
-rw-r--r-- | source/modules/asura-utils/Math/Rand/Rand.h | 1 | ||||
-rw-r--r-- | source/modules/asura-utils/Math/Vector2.hpp | 90 | ||||
-rw-r--r-- | source/modules/asura-utils/Math/Vector3.hpp | 2 |
4 files changed, 106 insertions, 107 deletions
diff --git a/source/modules/asura-utils/Math/Matrix44.h b/source/modules/asura-utils/Math/Matrix44.h index 7b66920..503242f 100644 --- a/source/modules/asura-utils/Math/Matrix44.h +++ b/source/modules/asura-utils/Math/Matrix44.h @@ -1,97 +1,95 @@ #ifndef _ASURA_MATRIX_H_ #define _ASURA_MATRIX_H_ +#include <asura-utils/Classes.h> + #include "../Scripting/Portable.hpp" -namespace AsuraEngine -{ - namespace Math - { +namespace_begin(AsuraEngine) +namespace_begin(Math) - /// - /// ҪתõOpenGLglm::mat4 - /// https://blog.csdn.net/candycat1992/article/details/8830894 - /// - class Matrix44 - { - public: +/// ҪתõOpenGLglm::mat4 +/// https://blog.csdn.net/candycat1992/article/details/8830894 +class Matrix44 +{ +public: - static const Matrix44 Identity; + static const Matrix44 Identity; - Matrix44(); + Matrix44(); - Matrix44(const Matrix44& m); + Matrix44(const Matrix44& m); - ~Matrix44(); + ~Matrix44(); - void operator = (const Matrix44& m); + void operator = (const Matrix44& m); - void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far); + void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far); - Matrix44 operator * (const Matrix44 & m) const; + Matrix44 operator * (const Matrix44 & m) const; - void operator *= (const Matrix44 & m); + void operator *= (const Matrix44 & m); - const float* GetElements() const; + const float* GetElements() const; - void SetIdentity(); + void SetIdentity(); - void SetTranslation(float x, float y); + void SetTranslation(float x, float y); - void SetRotation(float r); + void SetRotation(float r); - void SetScale(float sx, float sy); + void SetScale(float sx, float sy); - void SetShear(float kx, float ky); + void SetShear(float kx, float ky); - void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy); + void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy); - void Translate(float x, float y); + void Translate(float x, float y); - void Rotate(float r); + void Rotate(float r); - void Scale(float sx, float sy); + void Scale(float sx, float sy); - void Transform(float x, float y, float angle, float sx, float sy, float ox, float oy); + void Transform(float x, float y, float angle, float sx, float sy, float ox, float oy); - /// - /// Multiplies this Matrix44 with a shear transformation. - /// @param kx Shear along the x-axis. - /// @param ky Shear along the y-axis. - /// - void Shear(float kx, float ky); + /// + /// Multiplies this Matrix44 with a shear transformation. + /// @param kx Shear along the x-axis. + /// @param ky Shear along the y-axis. + /// + void Shear(float kx, float ky); - void Ortho(float left, float right, float bottom, float top, float near, float far); + void Ortho(float left, float right, float bottom, float top, float near, float far); - ///// - ///// Transforms an array of vertices by this Matrix44. The sources and - ///// destination arrays may be the same. - ///// - ///// @param dst Storage for the transformed vertices. - ///// @param src The source vertices. - ///// @param size The number of vertices. - ///// - //void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const; + ///// + ///// Transforms an array of vertices by this Matrix44. The sources and + ///// destination arrays may be the same. + ///// + ///// @param dst Storage for the transformed vertices. + ///// @param src The source vertices. + ///// @param size The number of vertices. + ///// + //void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const; - /// - /// ʽ - /// - float Calculate(); + /// + /// ʽ + /// + float Calculate(); - private: +private: - /// - /// | e0 e4 e8 e12 | - /// | e1 e5 e9 e13 | - /// | e2 e6 e10 e14 | - /// | e3 e7 e11 e15 | - /// - float e[16]; + /// + /// | e0 e4 e8 e12 | + /// | e1 e5 e9 e13 | + /// | e2 e6 e10 e14 | + /// | e3 e7 e11 e15 | + /// + float e[16]; - }; +}; - } -} +namespace_end +namespace_end namespace AEMath = AsuraEngine::Math; diff --git a/source/modules/asura-utils/Math/Rand/Rand.h b/source/modules/asura-utils/Math/Rand/Rand.h index efda8db..74b1102 100644 --- a/source/modules/asura-utils/Math/Rand/Rand.h +++ b/source/modules/asura-utils/Math/Rand/Rand.h @@ -25,7 +25,6 @@ Xorshift 32: 20.6 10.7 ms 4 WELL 512: 43.6 55.1 ms 68 */ - // Xorshift 128 implementation // Xorshift paper: http://www.jstatsoft.org/v08/i14/paper // Wikipedia: http://en.wikipedia.org/wiki/Xorshift diff --git a/source/modules/asura-utils/Math/Vector2.hpp b/source/modules/asura-utils/Math/Vector2.hpp index f2405eb..326a57e 100644 --- a/source/modules/asura-utils/Math/Vector2.hpp +++ b/source/modules/asura-utils/Math/Vector2.hpp @@ -1,71 +1,71 @@ #ifndef _ASURA_ENGINE_VECTOR2_H__ #define _ASURA_ENGINE_VECTOR2_H__ -namespace AsuraEngine +#include <asura-utils/Classes.h> + +namespace_begin(AsuraEngine) +namespace_begin(Math) + +template <typename T> +class Vector2 { - namespace Math - { - template <typename T> - class Vector2 - { - public: - Vector2(); - Vector2(T X, T Y); +public: + Vector2(); + Vector2(T X, T Y); - template <typename U> - explicit Vector2(const Vector2<U>& vector); + template <typename U> + explicit Vector2(const Vector2<U>& vector); - void Set(T X, T Y); + void Set(T X, T Y); - T x; ///< X coordinate of the vector - T y; ///< Y coordinate of the vector - }; + T x; ///< X coordinate of the vector + T y; ///< Y coordinate of the vector +}; - template <typename T> - Vector2<T> operator -(const Vector2<T>& right); +template <typename T> +Vector2<T> operator -(const Vector2<T>& right); - template <typename T> - Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right); +template <typename T> +Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right); - template <typename T> - Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right); +template <typename T> +Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right); - template <typename T> - Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right); +template <typename T> +Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right); - template <typename T> - Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right); +template <typename T> +Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right); - template <typename T> - Vector2<T> operator *(const Vector2<T>& left, T right); +template <typename T> +Vector2<T> operator *(const Vector2<T>& left, T right); - template <typename T> - Vector2<T> operator *(T left, const Vector2<T>& right); +template <typename T> +Vector2<T> operator *(T left, const Vector2<T>& right); - template <typename T> - Vector2<T>& operator *=(Vector2<T>& left, T right); +template <typename T> +Vector2<T>& operator *=(Vector2<T>& left, T right); - template <typename T> - Vector2<T> operator /(const Vector2<T>& left, T right); +template <typename T> +Vector2<T> operator /(const Vector2<T>& left, T right); - template <typename T> - Vector2<T>& operator /=(Vector2<T>& left, T right); +template <typename T> +Vector2<T>& operator /=(Vector2<T>& left, T right); - template <typename T> - bool operator ==(const Vector2<T>& left, const Vector2<T>& right); +template <typename T> +bool operator ==(const Vector2<T>& left, const Vector2<T>& right); - template <typename T> - bool operator !=(const Vector2<T>& left, const Vector2<T>& right); +template <typename T> +bool operator !=(const Vector2<T>& left, const Vector2<T>& right); #include "Vector2.inc" - // Define the most common types - typedef Vector2<int> Vector2i; - typedef Vector2<unsigned int> Vector2u; - typedef Vector2<float> Vector2f; +typedef Vector2<int> Vector2i; +typedef Vector2<unsigned int> Vector2u; +typedef Vector2<float> Vector2f; - } -} +namespace_end +namespace_end namespace AEMath = AsuraEngine::Math; diff --git a/source/modules/asura-utils/Math/Vector3.hpp b/source/modules/asura-utils/Math/Vector3.hpp index 8da57cf..c526ace 100644 --- a/source/modules/asura-utils/Math/Vector3.hpp +++ b/source/modules/asura-utils/Math/Vector3.hpp @@ -230,4 +230,6 @@ namespace AsuraEngine } } +namespace AEMath = AsuraEngine::Math; + #endif
\ No newline at end of file |