Skip to content

Logical Error in Calculating Quaternion to axis angle. #11

@surajsubudhi10

Description

@surajsubudhi10

In quaternion.h

inline vec4 quaternion::ToAxisAngle()
    {
        vec4 result;
        
        const float angle  = 2.0f * acos(w);
        const float length = sqrt(1.0f - angle*angle);

        result.xyz = vec3(x, y, z) / length;
        result.w   = angle;

        return result;
}

At the time calculating length it should be length = sqrt(1.0f - w*w); . And we should also check for length != 0. As per your previous code we can get angle greater than 1 so at that time the length will be undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions