Don't click here unless you want to be banned.

LSL Wiki : ExampleGetRootRot

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are
This function can be used to get the rotation of the root object, even if
called from a child object.

-- Xylor Baysklef

rotation GetRootRot() {
    // If this object is not linked, or if it is the
    // root object, just return llGetRot
    integer LinkNum = llGetLinkNumber();
    if (LinkNum == 0 || LinkNum == 1)
        return llGetRot();
    // Otherwise take local rotation into account.
    // This is the rotation of this object with the
    // root object's rotation as the reference frame.
    rotation LocalRot = llGetLocalRot();
    // This uses the global coord system as the 
    // reference frame.
    rotation GlobalRot = llGetRot();
    // Reverse the local rotation, so we can undo it.
    LocalRot.s = -LocalRot.s;
    // Convert from local rotation to just root rotation.
    rotation RootRot = LocalRot * GlobalRot;
    // Make the sign match (mathematically, this isn't necessary, 
    // but it makes the rotations look the same when printed out).
    RootRot = -RootRot;
    return RootRot;

There is one comment on this page. [Display comments/form]