Compare commits

..

3 Commits

Author SHA1 Message Date
strangezak
3908aa6a10 Updated Docs 2021-03-14 18:29:07 -07:00
Zakary Strange
d0ae200589 Fix comment location 2021-03-11 11:54:36 -08:00
strangezak
30633daa77 Inline all functions 2021-03-11 11:52:05 -08:00
4 changed files with 3180 additions and 3322 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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. |

View File

@@ -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); \
} \ } \

View File

@@ -66,39 +66,14 @@ 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 to = HMM_Quaternion(0.5f, 0.5f, -0.5f, 0.5f);
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 result = HMM_Slerp(from, 0.5f, to); hmm_quaternion result = HMM_Slerp(from, 0.5f, to);
EXPECT_FLOAT_EQ(result.X, 0.28867513f); EXPECT_FLOAT_EQ(result.X, 0.28867513f);
EXPECT_FLOAT_EQ(result.Y, 0.28867513f); EXPECT_FLOAT_EQ(result.Y, 0.28867513f);
EXPECT_FLOAT_EQ(result.Z, -0.28867513f); EXPECT_FLOAT_EQ(result.Z, -0.28867513f);
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)