I am working with a game and drawing lines on the screen. I have a line given by two points A(x1, y1) and B(x2, y2). I am looking to find the new point C(x3,y3) that is closer to point A than B.
So for example if the length of line A,B is 20 (the known values) then I want to find point C such that the length of line A,C is 15.
I have this semi-working in the game thus far however I think I'm getting tripped up on a very small detail as it works but only if I draw the line in certain quadrants (like 30,30 and 45,15). Can anyone point me in the right direction as to where this is breaking down? Is it that the coordinate system of the game is different from the traditional axis in math (0,0 is top left and y increases from top)?
My current math is below:
c = current length of line n = amount to subtract from current length slope = (y2-y1)/(x2-x1) t = arctan(slope) x3 = x1 + ((c-n) * cos(t)) y3 = m * (x - x1) + y1
I then plot the line
x, y, x3, y3
Where x,y is my original starting point for the line (unchanged).