Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Point GetNewPointWithDistance(Point vertex, Point old, int newDistance)
- {
- double oldDistance = Math.Sqrt((vertex.X - old.X) * (vertex.X - old.X) + (vertex.Y - old.Y) * (vertex.Y - old.Y));
- double sina = Math.Abs(vertex.Y - old.Y) / oldDistance;
- double cosa = Math.Abs(vertex.X - old.X) / oldDistance;
- return new Point((int)Math.Round(vertex.X - newDistance * cosa), (int)Math.Round(vertex.Y - newDistance * sina));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement