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?
$\endgroup$ 33 Answers
$\begingroup$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)$.
$\endgroup$ 4 $\begingroup$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.
$\endgroup$ $\begingroup$To find the fourth coordinate of a 4 sided polygon except for trapezoid and kite but for rhombus, square, rectangle and parallelogram.
You can simply add first 2 given opposite coordinates then Subtract it by the opposite unknown coordinates.
E.g if ABCD is a rectangle and the coordinates are A(-4;8) B(-10;0) C(6;-12) D(x;y).
Determine the 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$$
$\endgroup$ 1