MCPcopy Index your code
hub / github.com/HandmadeMath/HandmadeMath / HMM_InvLookAt

Function HMM_InvLookAt

HandmadeMath.h:2041–2065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2039
2040COVERAGE(HMM_InvLookAt, 1)
2041static inline HMM_Mat4 HMM_InvLookAt(HMM_Mat4 Matrix)
2042{
2043 ASSERT_COVERED(HMM_InvLookAt);
2044 HMM_Mat4 Result;
2045
2046 HMM_Mat3 Rotation = {0};
2047 Rotation.Columns[0] = Matrix.Columns[0].XYZ;
2048 Rotation.Columns[1] = Matrix.Columns[1].XYZ;
2049 Rotation.Columns[2] = Matrix.Columns[2].XYZ;
2050 Rotation = HMM_TransposeM3(Rotation);
2051
2052 Result.Columns[0] = HMM_V4V(Rotation.Columns[0], 0.0f);
2053 Result.Columns[1] = HMM_V4V(Rotation.Columns[1], 0.0f);
2054 Result.Columns[2] = HMM_V4V(Rotation.Columns[2], 0.0f);
2055 Result.Columns[3] = HMM_MulV4F(Matrix.Columns[3], -1.0f);
2056 Result.Elements[3][0] = -1.0f * Matrix.Elements[3][0] /
2057 (Rotation.Elements[0][0] + Rotation.Elements[0][1] + Rotation.Elements[0][2]);
2058 Result.Elements[3][1] = -1.0f * Matrix.Elements[3][1] /
2059 (Rotation.Elements[1][0] + Rotation.Elements[1][1] + Rotation.Elements[1][2]);
2060 Result.Elements[3][2] = -1.0f * Matrix.Elements[3][2] /
2061 (Rotation.Elements[2][0] + Rotation.Elements[2][1] + Rotation.Elements[2][2]);
2062 Result.Elements[3][3] = 1.0f;
2063
2064 return Result;
2065}
2066
2067/*
2068 * Quaternion operations

Callers 1

TESTFunction · 0.85

Calls 3

HMM_TransposeM3Function · 0.85
HMM_V4VFunction · 0.85
HMM_MulV4FFunction · 0.85

Tested by

no test coverage detected