Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 // Get our global position including local offset
  2.                 position = gGlobalRegionPos + llGetPos();
  3.                 // Compute our relative position wrt to the beacon position
  4.                 relative_pos = gBeaconGlobalPos - position;
  5.                 // Calculate the distance between points
  6.                 distance = llVecMag(relative_pos);
  7.                 // Normalize the vector between the two points for the heading calc
  8.                 relative_pos = llVecNorm(<relative_pos.x, relative_pos.y, 0.0>);
  9.                 // Calculate the relative angle between the the two points, then
  10.                 //  convert into 0-359 degrees
  11.                 target_hdg = llAtan2(relative_pos.y, relative_pos.x) * RAD_TO_DEG;
  12.                 if( target_hdg < 0 ) target_hdg += 360;
  13.                 // Get our own compass heading and convert it into 0-350 degrees
  14.                 zangle = (vrot.z * RAD_TO_DEG);
  15.                 if( zangle < 0 ) zangle += 360;
  16.                 // Subtract the target heading from our compass heading to get the
  17.                 //  offset
  18.                 delta_angle = target_hdg - zangle;
  19.                 // To avoid rounding issues causing an integer greater than 180,
  20.                 //  to appear on the display, clip the delta angle to exactly 180.0
  21.                 if( delta_angle > 180.0 ) delta_angle = 180.0;
  22.                 if( delta_angle < -180.0 ) delta_angle = -180.0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement