How can I fit a rectangle or circle inside an arbitrary quadrilateral

This may be a question with more math, but I wanted to ask here because it is in the context of CS. I want to fit a rectangle inside another (arbitrary) ATV with the inscription quad having the greatest height and width. Since I think the algorithm will be similar, I am looking to see if I can do this with a circle.

To be more clear, this is what I mean as a bounding quadrilateral. enter image description here

Here are two examples of inscribed maximization that I am trying to achieve: enter image description hereenter image description here

, . , . , , , , , , .

: , w/h, (, 4: 3). , ( ).

+5
2

1) .
.
, . , .
( ), .

2) .
" ", . , , .

+4

4- , , .

CV. . , .

, . , , .

, 4 () :

    x   y
P1  -2  -5
P2  1   7
P3  4   5  
P4  3   -2

P1, . :

quadrilateral

. k 0: d. k - Y , X. d , d. ,

k=dy/dx
d=y1-k*x1

.

k_inv = 1/k
d_inv = -d/k

        k        d                        k         d
p1p2    4       3           p1p2_inv    0.25    -0.75
p2p3    -0.67   7.67        p2p3_inv    -1.5    11.5
p3p4    7       -23         p3p4_inv    0.14    3.29
p4p1    0.6     -3.8        p4p1_inv    1.67    6.33

, DIV/0 , .

, , k . P2 P3.

P2 y P2 P1 P3 .

a=p2p3_inv(y)-p1p2_inv(y)

x x = p2p3_inv (y) x = p1p2_inv (y) y y .

b_candidate_1 = y-p4p1(p2p3_inv(y))
b_candidate_2 = y-p4p1(p1p2_inv(y))
b_candidate_3 = y-P3p4(p2p3_inv(y))
b_candidate_4 = y-P3p4(p1p2_inv(y))

b. , , a * b.

excel, :

enter image description here

b 6,9, p2p3, b .

,

Rect    x       y
R1      0.65    -1.3
R2      0.65    5.6
R3      3.1     5.6
R4      3.1     -1.3

enter image description here

++ , , "".

, a b = a * b , , p1p2 P1 P2 ....

+1

All Articles