Skip to content

Feature request: Implement reflection matrix calculation #1370

@mariob92

Description

@mariob92

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions