forked from icaven/glm
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
Reflection matrices can be used to implement mirrors on arbitrary planes.
Implementation example, from one of my projects:
eq
contains the plane equation coefficients.
template <typename T, glm::qualifier Q = glm::defaultp>
constexpr glm::tmat4x4<T, Q> make_reflection_matrix(const glm::tvec4<T, Q> &eq)
{
return glm::tmat4x4<T, Q>(-2.0f * eq.x * eq.x + 1.0f, -2.0f * eq.x * eq.y, -2.0f * eq.x * eq.z, 0.0f,
-2.0f * eq.y * eq.x, -2.0f * eq.y * eq.y + 1.0f, -2.0f * eq.y * eq.z, 0.0f,
-2.0f * eq.z * eq.x, -2.0f * eq.z * eq.y, -2.0f * eq.z * eq.z + 1.0f, 0.0f,
-2.0f * eq.w * eq.x, -2.0f * eq.w * eq.y, -2.0f * eq.w * eq.z, 1.0f);
}
Metadata
Metadata
Assignees
Labels
No labels