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 = Javascript nécessaire 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:
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 :
and the quadrilaterall area, after reduction :

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 :
That is to solve the above equation in the only unknown BC

Of course the maximum value of AD is 2S/(CD.sin(D)) !

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 :