Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nan when up is aligned with target #428

Open
anvaka opened this issue May 10, 2021 · 1 comment
Open

Nan when up is aligned with target #428

anvaka opened this issue May 10, 2021 · 1 comment

Comments

@anvaka
Copy link
Contributor

anvaka commented May 10, 2021

I'm not sure what's the right way to fix this or even whether a fix is necessary. Just wanted to log it here:

// glMatrix version 3.3.0

// Note that both `up` and `direction` are the same
let q = mat4.getRotation([], mat4.targetTo([], [0, 0, -1], [0, 0, 0], [0, 0, 1]))

// Now all quaternion components are not numbers
assert(Number.isNaN(q[0]))
assert(Number.isNaN(q[1]))
assert(Number.isNaN(q[2]))
assert(Number.isNaN(q[3]))
@jnsmalm
Copy link

jnsmalm commented Aug 9, 2021

I have the same issue. Seems like it doesn't work when target is at 0, 0, 0. Why is that?

const matrix = glMatrix.mat4.targetTo(glMatrix.mat4.create(),
    [0, 5, 0], [0, 0, 0], [0, 1, 0])
let rot = glMatrix.mat4.getRotation(glMatrix.quat.create(), matrix)
console.log(rot) // Float32Array(4) [NaN, NaN, NaN, NaN]

This results in a quat with "NaN, NaN, NaN, NaN"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants