Advertisement
Guest User

jon jon

a guest
Oct 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public APPoint getTopRight()
  2. {
  3. double x = myWidth * Math.cos( myAngle );
  4. double y = myWidth * Math.sin( myAngle );
  5.  
  6. return new APPoint( myTopLeft.getX() + x,
  7. myTopLeft.getY() - y );
  8. }
  9.  
  10. public APPoint getBottomRight()
  11. {
  12. APPoint tr = getTopRight();
  13.  
  14. double x = myHeight * Math.sin( myAngle );
  15. double y = myHeight * Math.cos( myAngle );
  16.  
  17. return new APPoint( tr.getX() + x,
  18. tr.getY() + y );
  19. }
  20.  
  21. public APPoint getBottomLeft()
  22. {
  23. APPoint tl = getTopLeft();
  24.  
  25. double x = myHeight * Math.sin( myAngle );
  26. double y = myHeight * Math.cos( myAngle );
  27.  
  28. return new APPoint( tl.getX() + x,
  29. tl.getY() + y );
  30. }
  31.  
  32. public void draw( Graphics g )
  33. {
  34. APPoint topLeft = myTopLeft;
  35. APPoint topRight = getTopRight();
  36. APPoint bottomLeft = getBottomLeft();
  37. APPoint bottomRight = getBottomRight();
  38.  
  39. g.drawLine( (int)topLeft.getX(), (int)topLeft.getY(), (int)topRight.getX(), (int)topRight.getY() );
  40. g.drawLine( (int)bottomLeft.getX(), (int)topLeft.getY(), (int)bottomLeft.getX(), (int)bottomRight.getY());
  41. g.drawLine( (int)bottomLeft.getX(), (int)bottomRight.getY(), (int)topRight.getX(), (int)bottomRight.getY());
  42. g.drawLine( (int)topRight.getX(), (int)bottomRight.getY(), (int)topRight.getX(), (int)topRight.getY());
  43.  
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement