Jump to content

What direction is my avatar facing?


You are about to reply to a thread that has been inactive for 64 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

The wiki example can be generalized a bit:

// untested example:
string generalCompass (vector direction) 
{
    list DIRS =["W","NW","N","NE","E","SE","S","SW","W"];
    integer index = llCeil(3.5 - (4 * llAtan2(direction.y, direction.x) / PI));
    // I'd clean up the above math for clarity, but too lazy to debug. Off the top of my head. . .:
    // list DIRS = ["N","NE","E","SE","S","SW","W","NW"];
    // integer index = llRound(8*(llAtan2(direction.x,direction.y)/PI)); // llAtan2(x,y); returns clock-angles, whereas llAtan2(y,x); returns math angles. 
    return llList2String(DIRS, index);
}
// What direction is the position X with respect to where this object is?
//   generalCompass(X-llGetPos());
// What direction is object 'ob' facing? (assuming it has standard orientation, which avatars do, but many don't:
//   generalCompass(llRot2Fwd(llGetObjectDetails(ob,[OBJECT_ROTATION])));
// What direction am I or the avatar I'm attached to facing?
//   generalCompass(llRot2Fwd(llGetRot()));

 

Edited by Quistess Alpha
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 64 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...