Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. public static Point GetNewPointWithDistance(Point vertex, Point old, int newDistance)
  2.         {
  3.             double oldDistance = Math.Sqrt((vertex.X - old.X) * (vertex.X - old.X) + (vertex.Y - old.Y) * (vertex.Y - old.Y));
  4.             double sina = Math.Abs(vertex.Y - old.Y) / oldDistance;
  5.             double cosa = Math.Abs(vertex.X - old.X) / oldDistance;
  6.  
  7.             return new Point((int)Math.Round(vertex.X - newDistance * cosa), (int)Math.Round(vertex.Y - newDistance * sina));
  8.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement