$nav ===== Function: llAxes2Rot ===== rotation llAxes2Rot(vector fwd, vector left, vector up) Converts a rotation expressed as three vectors that make an orthonormal basis (i.e. a rotation in matrix form), to a LSL [[types/rotation]]. ===== Parameters ===== === fwd === A unit [[types/vector]] that is the X vector of the basis. === left === A unit vector that is the Y vector of the basis. It must be perpendicular to X for the function to return any meaningful results. === up === A unit vector that is the Z vector of the basis. It must be perpendicular to X and Y for the function to return any meaningful results. ===== Return value ===== Returns a [[types/rotation]] representing the same orientation. ===== Notes ===== * If the vectors are not unit vectors or not orthogonal, the function may return meaningless results. Under these circumstances, it may return unnormalized rotations in some cases. Most other functions that deal with rotations return them normalized. This is a rare exception. * The inverse operation (get the axes out of an LSL rotation) is done with [[llRot2Fwd]], [[llRot2Left]] and [[llRot2Up]]. ===== Short examples ===== rotation r; // This will set r to <0, 0, 1, 0> which is a rotation of 180° around the Z axis. r = llAxes2Rot(<-1, 0, 0>, <0, -1, 0>, <0, 0, 1>); // This will set r to <0.5, 0.5, 0.5, 0.5> which is a rotation that corresponds to a transposition of the axes. r = llAxes2Rot(<0, 1, 0>, <0, 0, 1>, <1, 0, 0>); This function will return a rotation similar to the one used by [[llLookAt]] (pointing its local Z towards the given point, and keeping its local X below the horizon). rotation LookAtRot(vector where) { where = llVecNorm(where - llGetPos()); vector local_y = llVecNorm(<0,0,1> % where); return llAxes2Rot(local_y % where, local_y, where); } ===== See also ===== * [[llRot2Fwd]] returns the X axis of an orthonormal basis, given a rotation. * [[llRot2Left]] returns the Y axis of an orthonormal basis, given a rotation. * [[llRot2Up]] returns the Z axis of an orthonormal basis, given a rotation.