# Point in right triangle given two points and an angle

Given $\triangle ABC$ with $\angle B = 90^\circ$, $\overline{AC}$ hypotenuse, known points $A = (x_a, y_a)$ and $B = (x_b, y_b)$, and known angle $\angle A = \theta$, how do I find $(x_c, y_c)$?

• You have not given enough information: How is $(x_c,y_c)$ defined, let alone $A$ and $B$? – David G. Stork Aug 6 '18 at 19:36
• I'm not sure I know what you mean. $(x_c, y_c)$ are the x- and y-coordinates of the point I'm trying to find, $A$ is an angle known ahead of time, and $B$ would then be $90 - A$ since this is a right triangle. – Benn Aug 6 '18 at 19:39

This is easiest with vectors. First calculate the vector from $B$ to $A$. This is simply: $$v_{BA}=(x_a-x_b, y_a-y_b)$$

Rotate that vector by 90 degrees. You do this by swapping its coordinates and negating one of them. Which one you negate doesn't matter, and the choice determines which of the two solutions you get: $$v^\perp_{BA} = (-(y_a-y_b),\ x_a-x_b) \text{ or } (y_a-y_b,\ -(x_a-x_b))$$

Note however that the vector you now have is still of length $|BA|$, though it is now pointing in the right direction to $C$ (if you start from $B$).

To scale the vector to the right length we need to multiply it by the factor $\frac{|BC|}{|BA|} = \tan\theta$: $$v_{BC} = v^\perp_{BA} \cdot \tan\theta$$

Lastly you add this vector to the coordinates of $B$ to get the coordinates of $C$:

$$(x_c,y_c) = (x_b-(y_a-y_b)\tan\theta, y_b+(x_a-x_b)\tan\theta)$$ or $$(x_c,y_c) = (x_b+(y_a-y_b)\tan\theta, y_b-(x_a-x_b)\tan\theta)$$

• This is perfect and easy to implement efficiently. Thanks! – Benn Aug 7 '18 at 13:24
• Good explanation. Drawing may help to understand it better. – yW0K5o Aug 7 '18 at 13:48

Write $$\sin^2\theta=(\frac{BC}{AC})^2=\frac{(x_c-x_b)^2+(y_c-y_b)^2}{(x_c-x_a)^2+(y_c-y_a)^2}\\\cos^2\theta=(\frac{AB}{AC})^2=\frac{(x_b-x_a)^2+(y_b-y_a)^2}{(x_c-x_a)^2+(y_c-y_a)^2}$$ You have two equations, with two unknowns. Notice that they are quadratic equations, so you will have two solutions, depending on which side of the $AB$ line you find point $C$.

C is on the perpendicular to segment AB by B. So $x_c, y_c$ can be parametrized by $\lambda$ : $x_c - x_b, y_c - y_b = \lambda * (y_b - y_a, x_a - x_b)$

Now compute the angle of angle CAB as a function of $\lambda$ and solve the equation (in $\lambda$) angle= $\theta$

• Could you say more about this? I'm drawn to this approach as I'm going to end up implementing this as part of a drawing algorithm. $\angle CAB$ will be defined as a constant up front (probably something like $10^\circ$ or $15^\circ$). – Benn Aug 7 '18 at 0:56
• from there you can use @Andrei's equation. Just replace $x_c$ and $y_c$ by the expression with lambda this way it makes a one unknown equation – Thomas Aug 7 '18 at 2:12

Picture 1

Let's move system of axises to point $O'(x_a,y_b)$, the coordinates of the points $A, B, C$ will change respectively.

Picture 2

Le's name $\angle O'AB=\alpha$. Also $\angle ABO' =90^o-\alpha$ and sum of angles on axis X must be $180^o$, $\angle CBX_c=\alpha$.

From $\triangle O'AB$ will find that $AB = \frac{y_b-y_a}{cos\alpha} (1)$

From $\triangle CBX_c$ will find that $BC = \frac{x_c-x_b+x_a}{cos\alpha} (2)$

From $\triangle ABC$ will find that $tg\theta= \frac{BC}{AB} (3)$

Put (1) and (2) into (3)

$tg\theta= \frac{BC}{AB}=\frac{\frac{x_c-x_b+x_a}{cos\alpha}}{\frac{y_b-y_a}{cos\alpha}} = \frac{x_c-x_b+x_a}{y_b-y_a}(4)$

From (4) $x_c = (x_b-x_a) + (y_b-y_a)*tg\theta (5)$

If we move to the original axises (see Picture 1) we need to add $x_a$ to (5)

So (5) become $x_c = (x_b-x_a) + (y_b-y_a)*tg\theta + x_a= x_b + (y_b-y_a)*tg\theta (6)$

Let's find $y_c$ from the condition that $\triangle O'AB$ is similar to $\triangle X_cBC$ because of $\angle O'AB = \angle X_cBC = \alpha$ and $\angle AO'B = \angle BX_cC = 90^o$

So $\frac{O'A}{BX_c}=\frac{O'B}{X_cC} (7)$ or

$\frac{y_b-y_a}{x_c-x_b+x_a}=\frac{x_b-x_a}{y_c} (7')$

From (7') $y_c=\frac{x_b-x_a}{y_b-y_a}* (x_c-x_b+x_a) (7'')$

Put (5) to (7'')

$y_c=\frac{x_b-x_a}{y_b-y_a}* ((x_b-x_a) + (y_b-y_a)*tg\theta-x_b+x_a) = (x_b-x_a)*tg\theta (7''')$

If we move to the original axises (see Picture 1) we need to add $y_b$ to (7''')

$y_c=(x_b-x_a)*tg\theta + y_b=y_b + (x_b-x_a)*tg\theta (8)$

Finding the second solution for $C'$ I leave to readers.

• Why do you align the triangle with the axes? The given points A and B can be anywhere and don't always have the same x-coordinate – Jaap Scherphuis Aug 8 '18 at 5:27
• Thank you for noticing this. I post the correct picture later. – yW0K5o Aug 8 '18 at 7:54
• I post new solution later. – yW0K5o Aug 8 '18 at 23:08

Do you know the length of the hypotenuse? If so, then there's actually more information than you need to solve the problem.

If you know the hypotenuse and the vertex coordinates of a leg:

The midpoint of the hypotenuse is equidistant from every vertex on a right triangle by Thales' Theorem. So be subtracting both sides from each other:

$$(x_c-x_b)^2+(y_c-y_b)^2=m^2/4=(x_c-x_a)^2+(y_c-y_a)^2$$

This gives you two solutions but each is resulting triangle is congruent to the other.

Alternatively, we know $$(x_c,y_c)$$ lies on a line perpendicular through B. From trigonometry, we know its length is $$\tan{\theta}$$ AB, where AB=length of AB.

$$(x_c,y_c)=(x_b,y_b)+\tan{\theta}AB(y_b-y_a,x_a-x_b)$$

It should be possible to derive the solution without having to handle any non-linear equations.