I have a line from (a, b) to (x, y), and I would like to draw a line starting at (x, y), with length ℓ, that makes an angle of θ with the original line.
How do I compute the coordinates of the endpoint of this new line? See the diagram:

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s nearly always simpler to use vector algebra for this kind of thing, rather than Cartesian coordinates. Let’s start by labelling the points:
Let R(θ) be the matrix that rotates by θ radians counter-clockwise:
Then compute:
v = B − A (the vector from A to B)
v̂ = v / |v| (the unit vector in the direction of v)
ŵ = R(−θ) v̂ (the unit vector in the direction of BC; your rotation is clockwise, so we need R(−θ) here, not R(θ))
w = ℓ ŵ (the vector of length ℓ in the direction of BC)
C = B + w
This approach avoids the need to compute an arctangent, which would need some care (if done naïvely, it runs into trouble when B is vertically above or below A; but most languages have a function like
atan2for handling this case).In any sensible programming language with a vector library you should be able to write this as a one-liner, perhaps like this: