common: add some rotation matrices
This commit is contained in:
parent
7887318def
commit
fab993ad8d
|
|
@ -167,6 +167,44 @@ glm::vec3 mangle_from_vec(const glm::vec3 &v)
|
|||
return mangle;
|
||||
}
|
||||
|
||||
glm::mat3x3 RotateAboutX(float t)
|
||||
{
|
||||
//https://en.wikipedia.org/wiki/Rotation_matrix#Examples
|
||||
|
||||
const float cost = cos(t);
|
||||
const float sint = sin(t);
|
||||
|
||||
return glm::mat3x3 {
|
||||
1, 0, 0, //col0
|
||||
0, cost, sint, // col1
|
||||
0, -sint, cost // col1
|
||||
};
|
||||
}
|
||||
|
||||
glm::mat3x3 RotateAboutY(float t)
|
||||
{
|
||||
const float cost = cos(t);
|
||||
const float sint = sin(t);
|
||||
|
||||
return glm::mat3x3{
|
||||
cost, 0, -sint, // col0
|
||||
0, 1, 0, // col1
|
||||
sint, 0, cost //col2
|
||||
};
|
||||
}
|
||||
|
||||
glm::mat3x3 RotateAboutZ(float t)
|
||||
{
|
||||
const float cost = cos(t);
|
||||
const float sint = sin(t);
|
||||
|
||||
return glm::mat3x3{
|
||||
cost, sint, 0, // col0
|
||||
-sint, cost, 0, // col1
|
||||
0, 0, 1 //col2
|
||||
};
|
||||
}
|
||||
|
||||
// Returns a 3x3 matrix that rotates (0,0,1) to the given surface normal.
|
||||
glm::mat3x3 RotateFromUpToSurfaceNormal(const glm::vec3 &surfaceNormal)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -224,6 +224,9 @@ void RandomDir(vec3_t dir);
|
|||
glm::vec3 CosineWeightedHemisphereSample(float u1, float u2);
|
||||
glm::vec3 vec_from_mangle(const glm::vec3 &m);
|
||||
glm::vec3 mangle_from_vec(const glm::vec3 &v);
|
||||
glm::mat3x3 RotateAboutX(float t);
|
||||
glm::mat3x3 RotateAboutY(float t);
|
||||
glm::mat3x3 RotateAboutZ(float t);
|
||||
glm::mat3x3 RotateFromUpToSurfaceNormal(const glm::vec3 &surfaceNormal);
|
||||
bool AABBsDisjoint(const vec3_t minsA, const vec3_t maxsA, const vec3_t minsB, const vec3_t maxsB);
|
||||
void AABB_Init(vec3_t mins, vec3_t maxs, const vec3_t pt);
|
||||
|
|
|
|||
Loading…
Reference in New Issue