Skip to content

[feat.request] Quaternion LookAt #23

@Calvin1602

Description

@Calvin1602

There is no quaternion-based LookAt function. Ideally, this function would take a view direction, and an up vector. Here is one possible implementation, whi²ch assumes that the "front" of the object is towards +Z (should probably be an optional argument) :

vec3 right = cross(direction, desiredUp);
desiredUp = cross(right, direction); // re-orthogonalize

quat rot1 = RotationBetweenVectors(vec3(0.0f, 0.0f, 1.0f), direction);
vec3 newUp = rot1 * vec3(0.0f, 1.0f, 0.0f);
quat rot2 = RotationBetweenVectors(newUp, desiredUp);

return rot2 * rot1;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions