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

ti.ui.Camera.track_user_inputs without mouse movement will revert front vector when it is (0, 0, 1) #6653

Open
YouJiacheng opened this issue Nov 17, 2022 · 0 comments
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed welcome contribution

Comments

@YouJiacheng
Copy link

And this is the default value of front vector(postion=(0,0,0), lookat=(0,0,1))

import taichi as ti
from taichi.ui.utils import euler_to_vec, vec_to_euler
ti.init()
euler_to_vec(*vec_to_euler(ti.Vector([0, 0, 1]))) # output [-0. 0. -1.]
def vec_to_euler(v):
    v = v.normalized()
    pitch = asin(v[1])

    sin_yaw = -v[0] / cos(pitch)
    cos_yaw = -v[2] / cos(pitch)

    eps = 1e-6

    if abs(sin_yaw) < eps:
        yaw = 0
    else:
        yaw = acos(cos_yaw)
        if sin_yaw < 0:
            yaw = -yaw

    return yaw, pitch

I don't know why yaw = 0 when abs(sin_yaw) < eps.
I think using yaw = atan2(-v[0], -v[2]) can fix this problem. and simplify the code.

@YouJiacheng YouJiacheng added the potential bug Something that looks like a bug but not yet confirmed label Nov 17, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Nov 17, 2022
@PENGUINLIONG PENGUINLIONG self-assigned this Nov 18, 2022
@PENGUINLIONG PENGUINLIONG moved this from Untriaged to Todo in Taichi Lang Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed welcome contribution
Projects
Status: Todo
Development

No branches or pull requests

2 participants