Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public static Direction GetDirection4( Point3D from, Point3D to )
  2. {
  3. int dx = from.X - to.X;
  4. int dy = from.Y - to.Y;
  5.  
  6. int rx = dx - dy;
  7. int ry = dx + dy;
  8.  
  9. Direction ret;
  10.  
  11. if ( rx >= 0 && ry >= 0 )
  12. ret = Direction.West;
  13. else if ( rx >= 0 && ry < 0 )
  14. ret = Direction.South;
  15. else if ( rx < 0 && ry < 0 )
  16. ret = Direction.East;
  17. else
  18. ret = Direction.North;
  19.  
  20. return ret;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement