Question 545178
<pre>
It is always either possible to enclose a triangle in a rectangle
with sides parallel to the x and y axes such that either 

1. one vertex of the triangle coincides with a vertex of the rectangle
and the other two vertices are on sides of the triangle, as in the figure on the left, or

2. two vertices of the triangle coincide with two vertices of the rectangle,
as the figure on the right.

{{{drawing(400,2800/9,-1.2,8,-1,6, locate(-1.2,2,"B(p,q)"),locate(3,5.5,"A(r,s)"),
locate(7,0,"C(t,u)"),

green(line(0,0,0,5),line(0,5,7,5),line(7,5,7,0),line(7,0,0,0)),
line(0,2,3,5), line(3,5,7,0), line(7,0,0,2) )}}}     {{{drawing(400,2800/9,-1.2,8,-1,6, locate(-1.2,0,"B(p,q)"),locate(7,5.5,"A(r,s)"),
locate(5,1,"C(t,u)"),

green(line(0,0,0,5),line(0,5,7,5),line(7,5,7,0),line(7,0,0,0)),
line(0,0,5,1), line(5,1,7,5), line(7,5,0,0) )}}}  

For the figure on the left, we will label the coordinates of the
vertices of the other thre vertices of the rectangle:

{{{drawing(400,2800/9,-1.2,8,-1,6, locate(-1.2,2,"B(p,q)"),locate(3,5.5,"A(r,s)"), locate(-1,0,"D(p,u)"), locate(7,5.5,"E(t,s)"), locate(-1,5.5,"F(p,s)"),
locate(7,0,"C(t,u)"),

green(line(0,0,0,5),line(0,5,7,5),line(7,5,7,0),line(7,0,0,0)),
line(0,2,3,5), line(3,5,7,0), line(7,0,0,2) )}}} 

Rectangle FDCE = Triangle AFB + BDC + ACE + ABC

DC×CE = {{{1/2}}}AF×FB + {{{1/2}}}CD×BD + {{{1/2}}}AE×CE + X

Multiply through by 2

2×DC×CE = AF×FB + CD×BD + AE×CE + 2X

2(t-p)(s-u) = (r-p)(s-q) + (t-p)(q-u) + (t-r)(s-u) + 2X

2ts-2tu-2ps+2pu = rs-rq-ps+pq + tq-tu-pq+pu + ts-tu-rs+ru + 2X

2ts-2tu-2ps+2pu-rs+rq+ps-pq-tq+tu+pq-pu-ts+tu+rs-ru = 2X

 ts - ps + pu + rq - tq - ru = 2X

-ru + st + pu - tq - ps + rq = 2X

Multiply both sides by -1

 ru - st - pu + tq + ps - rq = -2X

The left side is a 3×3 determinant expanded by the 3rd column:

{{{abs(matrix(3,3,p,q,1,r,s,1,t,u,1))}}} = -2A

Multiplying both sides by {{{1/2}}} and taking absolute values:

A = {{{expr(1/2)*abs(abs(matrix(3,3,p,q,1,r,s,1,t,u,1)))}}}
 
In case one of the sides is horizontal or vertical, it just
amounsts to one of the triangles degenerating into a line
segment with 0 area.

----------------------------

For the other case you must include an additional rectangle, as
shown. I'll leave that derivation to you. It's entirely similar:

{{{drawing(400,2800/9,-1.2,8,-1,6, locate(-1.2,0,"B(p,q)"),locate(7,5.5,"A(r,s)"),
locate(5,1,"C(t,u)"),
green(line(0,0,0,5),line(0,5,7,5),line(7,5,7,0),line(7,0,0,0),line(5,0,5,1),line(5,1,7,1)),
line(0,0,5,1), line(5,1,7,5), line(7,5,0,0) )}}}

Edwin</pre>