Quadrilateral

To find a convex quadrilateral ABCD with given side CD, given angles at C and D, and a given area.
Given data  CD =
 Angle C = deg 
 Angle D = deg 
 Area =
Direct calculate :   AD =
 BC =
 
Solve for BC with given AD :   AD =
Solve with AD = BC : 
Solve with AB parallel to CD : 
Solve with angle A = 90° 

This script doesn't check for degenerate cases ("negative" sides, not convex etc.)

The method

Consider the quadrilateral in a coordinate system with origin D = {0,0} and CD along the x-axis : C = {CD, 0}
The coordinates of A and B are then:
A = {xA = AD.cos(D), yA = AD.sin(D)}
B = {xB = CD - BC.cos(C), yB = BC.sin(C)} (beware of the sign !)

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 = ( (xB - xD)(yA - yD) - (yB - yD)(xA - xD) )/2
This simplifies as xD = yD = 0 into :
Area(ABD) = (xB.yA - yB.xA)/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² = (xB - xA)² + (yB - yA

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° !

Solving with constraints

There is a full continuum of solutions with different values for unknown sides AD and BC
We have the above equation Area(ABCD) = f(AD, BC) = S, in the two unknowns AD and BC.
We may constrain these two unknowns to get specific solutions, from some additional relation in AD and BC :
  1. Fixed AD
    That is to solve the above equation in the only unknown BC

    BC = (2S - CD.AD.sin(D)) / (CD.sin(C) - AD.sin(C+D))
    Of course the maximum value of AD is 2S/(CD.sin(D)) !

  2. AD = BC
    That is, with AD = BC = x in the area formula, the quadratic :

    x²sin(C+D) - x.CD.(sin(C) + sin(D)) + 2S = 0

  3. AB // CD
    That is from yA = yB : AD.sin(D) = BC.sin(C)
    or AD = BC.sin(C)/sin(D), and pluging this into the area formula above, the quadratic in x = BC :

    x²sin(C+D).sin(C)/sin(D) - 2x.CD.sin(C) + 2S = 0

  4. Angle A = 90°
    This is the scalar product AD.AB = 0
    That is xA(xB - xA) + yA(yB - yA) = 0 (as xD = yD = 0 !)
    Substituting the values and reducing gives :

    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

 

 

Home Arithmetic Geometric Misc Topics Scripts Games Exercices Mail Version Française Previous topic Next topic