Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get our global position including local offset
- position = gGlobalRegionPos + llGetPos();
- // Compute our relative position wrt to the beacon position
- relative_pos = gBeaconGlobalPos - position;
- // Calculate the distance between points
- distance = llVecMag(relative_pos);
- // Normalize the vector between the two points for the heading calc
- relative_pos = llVecNorm(<relative_pos.x, relative_pos.y, 0.0>);
- // Calculate the relative angle between the the two points, then
- // convert into 0-359 degrees
- target_hdg = llAtan2(relative_pos.y, relative_pos.x) * RAD_TO_DEG;
- if( target_hdg < 0 ) target_hdg += 360;
- // Get our own compass heading and convert it into 0-350 degrees
- zangle = (vrot.z * RAD_TO_DEG);
- if( zangle < 0 ) zangle += 360;
- // Subtract the target heading from our compass heading to get the
- // offset
- delta_angle = target_hdg - zangle;
- // To avoid rounding issues causing an integer greater than 180,
- // to appear on the display, clip the delta angle to exactly 180.0
- if( delta_angle > 180.0 ) delta_angle = 180.0;
- if( delta_angle < -180.0 ) delta_angle = -180.0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement