Last active
March 19, 2020 01:54
-
-
Save lexmart/b68b2de5e60724dbd650adf9a931491e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct M44 | |
{ | |
union | |
{ | |
struct | |
{ | |
float m00, m01, m02, m03; | |
float m10, m11, m12, m13; | |
float m20, m21, m22, m23; | |
float m30, m31, m32, m33; | |
}; | |
float data[16]; | |
}; | |
}; | |
inline M44 operator*(M44 a, M44 b) | |
{ | |
#define DOTROW(row,col) a.m##row##0 * b.m0##col + a.m##row##1 * b.m1##col + a.m##row##2 * b.m2##col + a.m##row##3 * b.m3##col | |
M44 result = | |
{ | |
DOTROW(0, 0), DOTROW(0, 1), DOTROW(0, 2), DOTROW(0, 3), | |
DOTROW(1, 0), DOTROW(1, 1), DOTROW(1, 2), DOTROW(1, 3), | |
DOTROW(2, 0), DOTROW(2, 1), DOTROW(2, 2), DOTROW(2, 3), | |
DOTROW(3, 0), DOTROW(3, 1), DOTROW(3, 2), DOTROW(3, 3) | |
}; | |
#undef DOTROW | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment