Artificial intelligent assistant

Calculating coordinates OK, I have a picture which will hopefully make my explanation a bit clearer. !Image explaining my problem I have a line $(a, b)$ to $(x, y)$ and all I know is the end points of the line. I am trying to draw a line from the end point of the original line. It will have an angle of $\theta$ from the original line and a length of $l$. Based on these two values I need to work out the coordinates of the end point of this new line. Length l can be any positive value. Angle theta can lie anywhere from $-80^\circ$ to $+80^\circ$. Thanks for any help you can provide! ::Gets out pen and paper and starts scribbling::

First, find the x and y components of the line from (a,b) to (x,y).

If we draw a horizontal line from (x,y), we can see that the angle between the extension of the (a,b) to (x,y) line and the horizontal is equal to angle Q because they are alternate interior angles. Since we're given angle R, the angle between the line from (x,y) to (c,d) and the horizontal is Q - R.

Now that we have that angle, we can find the x and y components of the second line segment. The x component is $l \cos(R-Q)$ and the y component is $l \sin(Q-r)$.

Adding components, we find that if (a,b) is the origin, (c,d) is at: $$(x+l \cos(R-Q), y+l \sin(Q-R))$$

If (a,b) is not at the origin, we simply shift (c,d):

$$(c,d) = (a+x+l \cos(R-Q), b+y+l \sin(Q-R))$$

Note: $\angle Q = Tan^{-1}(y/x)$

!Triangles

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 62d4df2f2fc6475640fb2497fd043a78