1
$\begingroup$

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?

  • 1
    $\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} $2012-03-18

3 Answers 3

5

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)$.

  • 0
    @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.2012-05-13
1

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.

0

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$

  • 0
    It usually is not ne$c$essary to give your name, $d$ate, or email. The site records all this information.2014-08-19