Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def look_at(u, v):
- u.normalize()
- v.normalize()
- dot = u.dot(v)
- cross = u.cross(v)
- q = mathutils.Quaternion()
- q.x = cross.x
- q.y = cross.y
- q.z = cross.z
- q.w = math.sqrt(u.length_squared*v.length_squared) + dot
- q.normalize()
- print(q)
- return q
- def look_at(u, v):
- u.normalize()
- v.normalize()
- dot = u.dot(v)
- cross = u.cross(v)
- q = mathutils.Quaternion()
- if dot >= 1.0:
- print("Case 1")
- return q.identity()
- elif dot < 0.000001 - 1.0:
- print("Case 2")
- else:
- print("Case 3")
- s = math.sqrt((1+dot)*2)
- invis = 1/s
- q.x = cross.x * invis
- q.y = cross.x * invis
- q.z = cross.x * invis
- q.w = s * 0.5
- q.normalize()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement