SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                     Vector2 d = new Vector2(0, 0);
  2.  
  3.                     float Fi = getAngle(message.getLoc(), bwNode.getLoc());
  4.  
  5.                     d.x = Math.cos(Fi);
  6.                     d.y = Math.sin(Fi);
  7.  
  8.                     Vector2 PT = new Vector2(0, 0);
  9.                     PT.x = (message.getLoc().getX() - bwNode.getLoc().getX());
  10.                     PT.y = (message.getLoc().getY() - bwNode.getLoc().getY());
  11.  
  12.                     double perplen = Math.abs(PT.x * d.y - PT.y * d.x);
  13.  
  14.                     double alonglen = Math.abs(PT.x * d.x + PT.y * d.y);
  15.  
  16.                     if(perplen <= AreaWidth/2){
  17.                         if(alonglen >= 0 && alonglen <= AreaLength){
  18.                            
  19.                                 DO STUFF
  20.  
  21.                             }
  22.                         }
  23.                     }
  24.  
  25.  
  26. public float getAngle(Point player, Point target) {
  27.         float angle = (float) Math.toDegrees(Math.atan2(target.getY() - player.getY(), target.getX() - player.getX()));
  28.  
  29.         if(angle < 0){
  30.             angle += 360;
  31.         }
  32.  
  33.         return angle;
  34.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top