Finding diagonal length of quadrilateral using ( for each number block )

I am trying to find solutions to find the unknown diagonal of an irregular quadrilateral, given its area and the lengths of its four sides.

TOTAL AREA = △1 AREA + △2 AREA
Using Heron's Formula
herons-formula

All values ​​are known in the equation except the length of the diagonal X

I used the ( for each number from to ) block to test the numbers that give the same area result, but unfortunately it doesn't work. I don't know what the problem is !! aia file attached

blocks(124)
blocks(125)
blocks(123)

find_diagonal_of_a_quadrilateral(1).aia (93.1 KB)

example results


The long running for loop is blocking the UI,, which results in that error after a while

Use a fast running clock component instead

Taifun

1 Like

There are some mathematical issues regarding your approach.

  • Not all areas can be fitted into a particular set of side lengths. Some may be too large or too small. You don't check for that before sending your app on an impossible task.

  • You check for an exact match, assuming the diagonal to be a rational number that can be enumerated, and assuming that the floating point calculation results will match exactly.

A more appropriate approach would be to use Newton's Method in a Clock Timer to run its steps until you get within some small distance of a solution.

1 Like

Additional thoughts:

  • Your diagonal length iteration range can be made shorter, starting at max(abs(A-B),abs(C-D)) and ending at min(A+B,C+D)

  • You can use a courser iteration step for a first approximation, like min(A,B,C,D)/10 and then use that to home in on a shorter range once you know which sub-range is closest to the solution

If you calculate the difference between target area and calculated area, you would be searching for zero crossings, a known mathematical technique.

P.S. AI2 has easy graph components that could be used to graph the area difference across the domain of diagonal lengths. That could be used to show the iterative nature of the calculations as you home in on the smaller diagonal domains.

This is just to add a bit of showmanship to the app, and to help the viewer see how the process works.

I did not address the nature of the assignment.

Is this a test of coding ability, or a test of knowledge of the trigonometric functions and construction techniques that would result in the creation of a trigonometric formula that should be solved symbolically?

What method did you use to calculate the area of the polygon in the first place ?

The area formula you gave us (Heron) can be expanded into a fourth degree polynomial in x.

The big fat ugly general solution to those is at

https://www.researchgate.net/figure/Roots-of-fourth-order-polynomial-equation_fig13_47715135