Hi Ferdinand,
thanks a lot, seems I'm not the only one missing the good weather outside .-)
The code in the first lookat() function should be abs(ri.x - 1.0),
this comes from the post in the mentioned link. I corrected that in the original post.
(it was just missing in the post, my code had the ri.x)
what I'm on to is a 2 axis ceiling spot.
its a null with a python tag having a target link userdata, then inside a hierarchy with two axes.
atm they are driven by 2 target tags (initialized by the pyTag) one needs pitch on, one needs pitch off.
this works fine, but as i have 900 of these in a file,
i am trying to get rid of the target tags and do all in the pyTag.
I can post the file tomorrow.
what happens with my lookat() is that if you move the target,
the spot sometimes turns upside down 180 degrees and sticks in the ceiling.
with lookatQ() the spot simply doesn't point in the correct direction.
but it would be very interesting to learn how to do it with quaternions.
edit: your solution seems to work nicely, btw!
p.s. i guess ~ is normalise and % is the cross product