rotation llRotBetween(vector a, vector b);
Returns the
rotation needed to rotate from
a to
b, with a center of rotation at
<0,0,0>.
Note:
Be sure to normalize a and b before using llRotBetween, with llVecNorm. This automatically prevents any quirkiness on the part of this function.
vector a = <0,0,1>;
vector b = <1,0,0>;
rotation between = llRotBetween(a, b);
//Ignoring float precision loss these statements below are true.
//a * between == b
//b / between == a
Q: Wuh?
A: Imagine a cube with an arrow sticking out of it. The base of the arrow is in the center of the cube, and we'll call that <0,0,0> (see next question). This arrow is vector
a (a
forward vector, if you will). After some arbitrary rotation, the base of the arrow is in the same place, but it's pointing off in some other direction, that's vector
b. So, given vector
a which is the way the cube is facing now, and vector
b, the way you want to be facing, this function returns the rotation you need to get from here to there.
Q: What is a 'center of rotation'?
A: The center of rotation would be the center of the object that is rotating (the parent object of a link set). The math of this function assumes that the object's center is at <0,0,0>, so if you're getting your vectors from world-coordinates, make sure to subtract the task's position from them.
Functions /
Rotation