# How do I Find all Angles of 4-sided polygon given side lengths?

I have a program that lets users draw custom 4-sided shapes using java 2d. I want to calculate the angles inside the shapes so I can rotate text to the proper angle and label each side.

I am trying to calculate all angles of a 4-sided polygon given the length of all 4 sides. I found a formula using law of cosines for a cyclic quadrilateral, but I don't know that all of my shapes will be cyclic since they are user defined and can be any 4 points in a 2d coordinate system.

Is my only option to find the diagonals and start piecing it together with law of cosines for each triangle?

-
Don't you have the coordinates of the vertices? If so, the easiest option would be to find the angle of each side with, say, the $x$-axis, and then subtract appropriately. –  Rahul Mar 18 '12 at 8:35
I do have the coordinates of all 4 points. Can you elaborate on how this would be done? –  jimdrang Mar 18 '12 at 8:40
$$\alpha = \arctan \left|\frac{m_1-m_2}{1+m_1m_2}\right|$$ , where : $$m_1=\frac{y_D-y_A}{x_D-x_A} , m_2=\frac{y_B-y_A}{x_B-x_A}$$ –  pedja Mar 18 '12 at 8:50

The lengths don't determine the angles: for example with all sides equal you have a rhombus, where the angle at any vertex could be anything in the interval $(0, \pi)$.

-
So you are saying what I want to do is not possible? Even if I can rule out special cases like all sides being equal? –  jimdrang Mar 18 '12 at 8:48
That's correct. Imagine having four girders of the right lengths, and attaching the ends with joints that can turn freely. The frame that you'd have would not be rigid; you could vary all the angles. Therefore, you can't calculate the angles given the four sides, unless you have an extra piece of information (like knowing the length of one diagonal; or knowing that the quadrilateral is cyclic). –  user22805 Mar 18 '12 at 9:01
Ok, I'm having trouble figuring out if you are telling me this is not possible at all or just the way I stated the question. So if I change the question title to given 4 (x,y) coordinates, it would be possible using the right triangles I can create using the x and y axis? –  jimdrang Mar 18 '12 at 9:15
@jimdrang: If you know the coordinates, then the points are fixed, and so are the angles. You can find the angles using the cosine formula, as you said. –  Beni Bogosel May 13 '12 at 16:29

If you know the (x,y) coordinates, then you also the lengths of the diagonals and you can use the law of cosines to find the angles.

-

To find the fourth coordinate of 4 sided angles except for trapezoid and kite but for rhombus square rectangle and parallelogram.

You simple add given coordinates which makes a digonal then Subtract it by the opposite coordinate of the wanted coordinates.

E.g if ABCD is a rectangle and the coordinates are A(-4;8) B(-10;0) C(6;-12) D(x;y).

Find coordinates of D!

SOLUTION

$$A+C-B=D$$

$$(-4;8)+(6;-12)-(-10;0)=D$$

$$(-4+6--10;8+-12--0)=D$$

$$(-4+16;8-12)=D$$

$$(12;-4)=D$$

-
It usually is not necessary to give your name, date, or email. The site records all this information. –  Vladhagen Aug 19 '14 at 20:34