3

I am writing a program in java. I looking for formula to determine the 3rd point in a triangle if the length of all sides and the coordinates of two points are known.

Ross Millikan
  • 383,099
  • 4
    Note that in the general case there are $4$ answers. – André Nicolas Jan 25 '14 at 04:19
  • 4
    To make Andre's comment a bit less elliptical: note that for the purposes of trying to cook up such a 'formula' you can assume, without loss of generality, that the two points you know lie on the x axis. (You may even assume that the origin is their midpoint.) Now try to think about why knowing the lengths doesn't determine the third point uniquely. – symplectomorphic Jan 25 '14 at 04:25
  • See also http://math.stackexchange.com/q/543961/35416 – MvG Nov 04 '14 at 17:51
  • Do you know which side length corresponds to each known point? – Dan May 18 '22 at 22:50

3 Answers3

1

Consider what you'd do with ruler and compass. Suppose your two known points are $A$ and $B$, then you'd draw a circle around $A$ with radius $AC$ and a circle around $B$ with radius $BC$. These circles would intersect in two points, either of which would qualify as $C$ unless you know the orientation of the triangle. To replicate this in a program, you have to implement (or find a library to compute) the intersection of two circles.

Since your question is tagged trigonometry, have a look at the cosine law. It allows you to compute (the cosine of) an angle given the three lengths of a triangle. So you can know how far along the line $AB$ you have to go, and using the Pythagorean theorem or some altitude formula you can also compute how far you have to go perpendicular to that line, in order to find $C$.

To be more precise, if $D$ is the point on line $AB$ such that both $\triangle ADC$ and $\triangle BDC$ have a right angle at $D$, then the cosine law gives you

\begin{align*} \lvert AD\rvert &= \frac{\lvert AB\rvert^2+\lvert AC\rvert^2-\lvert BC\rvert^2} {2\,\lvert AB\rvert} \\ \lvert BD\rvert &= \frac{\lvert AB\rvert^2+\lvert BC\rvert^2-\lvert AC\rvert^2} {2\,\lvert AB\rvert} \\ \lvert CD\rvert &= \frac{\sqrt{ \left(\lvert AB\rvert + \lvert AC\rvert + \lvert BC\rvert\right) \left(\lvert AB\rvert + \lvert AC\rvert - \lvert BC\rvert\right) \left(\lvert AB\rvert - \lvert AC\rvert + \lvert BC\rvert\right) \left(-\lvert AB\rvert + \lvert AC\rvert + \lvert BC\rvert\right) }}{2\,\lvert AB\rvert} \end{align*}

MvG
  • 44,006
1

You can use Heron's Formula to find the area of your triangle, $T$.

You can use a matrix determinant to find the area in another way:

$$\frac 12 \det \begin{bmatrix} B_x - A_x & C_x - A_x \\ B_y - A_y & C_y - A_y \end{bmatrix} = T$$

That gives you a linear equation between $C_x$ and $C_y$: $$(A_y - B_y)C_x + (B_x - A_x)C_y = 2 T - A_xB_y + A_yB_x \tag{1}$$

One more equation to fully characterize the system:

$$(A_x - C_x)^2 + (A_y - C_y)^2 = |AC|^2 \tag{2}$$

Solve (1) for $C_x$ (or $C_y$ if you want) and plug that into (2) and solve the resulting quadratic.

DanielV
  • 24,386
0

Let $A$ and $B$ be the two points with known coordinates, and we want to find the coordinates of point $C$. Since the side lengths are known than if $\theta = \angle CAB$ then

$ \cos(\theta) = \dfrac{ c^2 + b^2 - a^2 }{2 b c} $

Define the unit vector $ u = \dfrac{ B - A }{ c } $

Assuming $ u = (u_x, u_y)$, define the two unit vectors perpendicular to $u$ as follows

$ v_1 = (- u_y, u_x ) $ and $v_2 = - v_1 = (u_y, -u_x) $

Then we have two possible locations for point $C$, the first one is

$ C = A + b \cos(\theta) u + b \sin(\theta) v_1 $

and the second is

$ C = A + b \cos(\theta) u + b \sin(\theta) v_2 $