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

Add rotation from 3 vectors (x,y,z) #46

Open
adamlwgriffiths opened this issue Jun 12, 2017 · 0 comments
Open

Add rotation from 3 vectors (x,y,z) #46

adamlwgriffiths opened this issue Jun 12, 2017 · 0 comments
Assignees

Comments

@adamlwgriffiths
Copy link
Owner

Need to be able to create a matrix / quaternion from 2/3 vectors (forward, up, left/right).

As mentioned in #30, pyeuclid has this code
From PyEuclid (https://code.google.com/p/pyeuclid/source/browse/trunk/euclid.py)

def new_look_at(cls, eye, at, up):
  z = (eye - at).normalized()
  x = up.cross(z).normalized()
  y = z.cross(x)

  m = cls.new_rotate_triple_axis(x, y, z)
  m.d, m.h, m.l = eye.x, eye.y, eye.z
  return m

def new_rotate_triple_axis(cls, x, y, z):
  m = cls()

  m.a, m.b, m.c = x.x, y.x, z.x
  m.e, m.f, m.g = x.y, y.y, z.y
  m.i, m.j, m.k = x.z, y.z, z.z

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

No branches or pull requests

1 participant