We can now directly calculate the area of quadrilateral as the
sum of areas of triangles ABD and BCD
Triangle BCD area = CD.BC.sin(C)/2 (known formula, however base×height/2)
Triangle ABD area from coordinates uses the mixed "vector" product
||DB^{>}×DA^{>}||/2 =
( (x_{B} - x_{D})(y_{A} - y_{D}) - (y_{B} - y_{D})(x_{A} - x_{D}) )/2
This simplifies as x_{D} = y_{D} = 0 into :
Area(ABD) = (x_{B}.y_{A} - y_{B}.x_{A})/2 =
((CD - BC.cos(C)).AD.sin(D) - BC.sin(C).AD.cos(D))/2
and the quadrilaterall area, after reduction :
S = (CD.BC.sin(C) + CD.AD.sin(D) - BC.AD.sin(C+D))/2 |
A small check : if angles are exactly 90° we get S = CD.(BC + AD)/2, the area of a trapezoid
The other unknowns are side AB, directly obtained from AB² = (x_{B} - x_{A})² + (y_{B} - y_{A})²
Angle A is obtained from cosinus law in triangle ABD cos(A) = (AB² + AD² - BD²) / (2.AB.AD)
Angle B from cosinus law in triangle BCD
cos(B) = (AB² + BC² - AC²) / (2.AB.BC)
Or even simpler from A + B + C + D = 360° !
BC = (2S - CD.AD.sin(D)) / (CD.sin(C) - AD.sin(C+D)) |
x²sin(C+D) - x.CD.(sin(C) + sin(D)) + 2S = 0 |
x²sin(C+D).sin(C)/sin(D) - 2x.CD.sin(C) + 2S = 0 |
BC = -(AD - CD.cos(D))/cos(C+D)
Note that we must have C+D > 90° ! Beware of the sign AD > CD.cos(D) and cos(C+D) < 0
If C = D = 90° the condition is equivallent to BC = AD (a true rectangle)
Pluging this into the area formula gives the quadratic in AD = x :
x²sin(C+D) - 2x.CD.sin(C) + CD²cos(D)sin(C) - 2S.cos(C+D) = 0 |