LlRotBetween
From Second Life Wiki
(Redirected from LSL llRotBetween)
| LSL Portal | | | Functions | | | Events | | | Types | | | Operators | | | Constants | | | Flow Control | | | Script Library | | | Tutorials |
Description
Function: rotation llRotBetween( vector start, vector end );| 21 | Function ID |
| 0.0 | Delay |
| 10.0 | Energy |
Returns a rotation that is the rotation between the direction start and the direction end
| • vector | start | |||
| • vector | end |
Specification
start and end are directions and are relative to the origin <0.0, 0.0, 0.0>. If you have coordinates relative to a different origin, subtract that origin from the input vectors.
Caveats
start * llRotBetween(start, end) == endis only true if start and end have the same magnitude and neither have a magnitude of zero (see #Notes for a workaround).
Examples
llRotBetween(<1.0, 0.0, 0.0>, <0.0, -1.0, 0.0>) // will return <0.00000, 0.00000, -0.70711, 0.70711> (which represents -45 degrees on the z axis) llRotBetween(<0.0, 0.0, 0.0>, <0.0, -1.0, 0.0>) // will return <0.00000, 0.00000, 0.00000, 1.00000> (which represents a zero angle on all axis) // because <0.0, 0.0, 0.0> does not convey a direction.
Notes
This function adjusts the magnitude of the quaternion so start * llRotBetween(start, end) == end is true as long as neither have a magnitude of zero. They don't have to have the same magnitude.
rotation RotBetween(vector start, vector end) //adjusts quaternion magnitude so (start * return == end) {//Authors note: I have never had a use for this but it's good to know how to do it if I did. rotation rot = llRotBetween(start, end); if(start) { if(end) { float d = llSqrt(llVecMag(end) / llVecMag(start)); return <rot.x * d, rot.y * d, rot.z * d, rot.s * d>; } } return rot; }//Strife Onizuka

