15,905,420 members
See more:
I have two points (x1, y1) and (x2,y2) and have a straight line between the 2 points. From the distance of the line I have to decrease some length (Percentage of the original length). How do I get the point where the new length is to draw a path between (x1,y1) & (x3,y3)

So far I have this and developed in WPF C#:

C#
```private void DrawPath(Point origination, Point destination, float decreasePct)
{
Canvas.Children.Clear();
var distance = GetLineLength(origination, destination);

var path = new PathFigure();

path.StartPoint = origination;

// Create a PathGeometry to contain the figure.
var pathGeometry = new PathGeometry();

// Display the PathGeometry.
var myPath = new Path {Stroke = Brushes.Black, StrokeThickness = 6, Data = pathGeometry};

}

private int GetLineLength(Point origination, Point destination)
{
var x = destination.X - origination.X;
var y = destination.Y - origination.Y;

var pyth = Math.Pow(x, 2) + Math.Pow(y, 2);

return (int)Math.Sqrt(pyth);
}```

Any help would be appreciated!!!
Posted

## Solution 1

of course it is
C#
```x3 = x1 + (x2-x1)*p/100;
y3 = y1 + (y2-y1)*p/100;```

Kavan Rathnayake 24-Jun-14 4:48am
Thanks :)
Feel so dumb atm
Thanks again
CPallini 24-Jun-14 5:13am
You are welcome.