mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2025-12-29 08:04:31 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3908aa6a10 | ||
|
|
d0ae200589 | ||
|
|
30633daa77 |
3262
HandmadeMath.h
3262
HandmadeMath.h
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,8 @@ To get started, go download [the latest release](https://github.com/HandmadeMath
|
|||||||
|
|
||||||
Version | Changes |
|
Version | Changes |
|
||||||
----------------|----------------|
|
----------------|----------------|
|
||||||
**1.12.1** | Added extra parentheses around some macros |
|
|
||||||
**1.12.0** | Added Unary Minus operator for `HMM_Vec2`, `HMM_Vec3`, and `HMM_Vec4`. |
|
**1.13.0** | Inline all Handmade Math functions. Remove need for HANDMADE_MATH_IMPLEMENTATION |
|
||||||
**1.11.1** | Added HMM_PREFIX macro to a few functions that were missing it. |
|
**1.11.1** | Added HMM_PREFIX macro to a few functions that were missing it. |
|
||||||
**1.11.0** | Added ability to customize or remove the default `HMM_` prefix on function names by defining a macro called `HMM_PREFIX(name)`. |
|
**1.11.0** | Added ability to customize or remove the default `HMM_` prefix on function names by defining a macro called `HMM_PREFIX(name)`. |
|
||||||
**1.10.1** | Removed stdint.h, this doesn't exist on some really old compilers and we didn't really use it anyways. |
|
**1.10.1** | Removed stdint.h, this doesn't exist on some really old compilers and we didn't really use it anyways. |
|
||||||
|
|||||||
@@ -58,7 +58,6 @@
|
|||||||
#define HANDMADETEST_H
|
#define HANDMADETEST_H
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -153,7 +152,7 @@ INITIALIZER(_HMT_COVERCASE_FUNCNAME_INIT(name)) { \
|
|||||||
_HMT_CASE_START(); \
|
_HMT_CASE_START(); \
|
||||||
float actual = (_actual); \
|
float actual = (_actual); \
|
||||||
float diff = actual - (_expected); \
|
float diff = actual - (_expected); \
|
||||||
if (isnan(actual) || diff < -FLT_EPSILON || FLT_EPSILON < diff) { \
|
if (diff < -FLT_EPSILON || FLT_EPSILON < diff) { \
|
||||||
_HMT_CASE_FAIL(); \
|
_HMT_CASE_FAIL(); \
|
||||||
printf("Expected %f, got %f", (_expected), actual); \
|
printf("Expected %f, got %f", (_expected), actual); \
|
||||||
} \
|
} \
|
||||||
@@ -163,7 +162,7 @@ INITIALIZER(_HMT_COVERCASE_FUNCNAME_INIT(name)) { \
|
|||||||
_HMT_CASE_START(); \
|
_HMT_CASE_START(); \
|
||||||
float actual = (_actual); \
|
float actual = (_actual); \
|
||||||
float diff = actual - (_expected); \
|
float diff = actual - (_expected); \
|
||||||
if (isnan(actual) || diff < -(_epsilon) || (_epsilon) < diff) { \
|
if (diff < -(_epsilon) || (_epsilon) < diff) { \
|
||||||
_HMT_CASE_FAIL(); \
|
_HMT_CASE_FAIL(); \
|
||||||
printf("Expected %f, got %f", (_expected), actual); \
|
printf("Expected %f, got %f", (_expected), actual); \
|
||||||
} \
|
} \
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ TEST(QuaternionOps, NLerp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(QuaternionOps, Slerp)
|
TEST(QuaternionOps, Slerp)
|
||||||
{
|
|
||||||
// Normal operation
|
|
||||||
{
|
{
|
||||||
hmm_quaternion from = HMM_Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
|
hmm_quaternion from = HMM_Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
hmm_quaternion to = HMM_Quaternion(0.5f, 0.5f, -0.5f, 0.5f);
|
hmm_quaternion to = HMM_Quaternion(0.5f, 0.5f, -0.5f, 0.5f);
|
||||||
@@ -78,29 +76,6 @@ TEST(QuaternionOps, Slerp)
|
|||||||
EXPECT_FLOAT_EQ(result.W, 0.86602540f);
|
EXPECT_FLOAT_EQ(result.W, 0.86602540f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same quat twice
|
|
||||||
{
|
|
||||||
hmm_quaternion q = HMM_Quaternion(0.5f, 0.5f, 0.5f, 1.0f);
|
|
||||||
|
|
||||||
hmm_quaternion result = HMM_Slerp(q, 0.5f, q);
|
|
||||||
EXPECT_FLOAT_EQ(result.X, 0.5f);
|
|
||||||
EXPECT_FLOAT_EQ(result.Y, 0.5f);
|
|
||||||
EXPECT_FLOAT_EQ(result.Z, 0.5f);
|
|
||||||
EXPECT_FLOAT_EQ(result.W, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Identity quat twice
|
|
||||||
{
|
|
||||||
hmm_quaternion q = HMM_Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
hmm_quaternion result = HMM_Slerp(q, 0.5f, q);
|
|
||||||
EXPECT_FLOAT_EQ(result.X, 0.0f);
|
|
||||||
EXPECT_FLOAT_EQ(result.Y, 1.0f);
|
|
||||||
EXPECT_FLOAT_EQ(result.Z, 0.0f);
|
|
||||||
EXPECT_FLOAT_EQ(result.W, 1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(QuaternionOps, QuatToMat4)
|
TEST(QuaternionOps, QuatToMat4)
|
||||||
{
|
{
|
||||||
const float abs_error = 0.0001f;
|
const float abs_error = 0.0001f;
|
||||||
|
|||||||
Reference in New Issue
Block a user