move point towards other point code example
Example: move point towards other point
public Point MovePointTowards(Point a, Point b, double distance)
{
var vector = new Point(b.X - a.X, b.Y - a.Y);
var length = Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
var unitVector = new Point(vector.X / length, vector.Y / length);
return new Point(a.X + unitVector.X * distance, a.Y + unitVector.Y * distance);
}