3

suppose we have a box defined by coordinates $(1,1)$, $(-1,1)$, $(-1,-1)$, $(1,-1)$. Suppose, a line $y=m(x+b)$ crosses the box with $m>0$ and $b>0$. What is the area of left upper triangle. Assume that the line crosses the box. Thank you very much.

Partial Answer:

the line intersects a box at $(x,y)=(\frac{1}{m}-b,1)$ and $(x,y)=(-1,m(b-1))$

Area is formed by $(-1-(\frac{1}{m}-b)) \cdot (1-m(b-1))$ ,correct?

Boby
  • 5,985
  • I got something like this: Area=$2-2mb-2b+m+mb^2+\frac{1}{m}$. Is this correct? – Boby Aug 13 '14 at 18:53
  • For some values of $m,b$, your area will be zero because the line doesn't intersect the box. It doesn't appear that your answer takes this into account. – John Aug 13 '14 at 18:58
  • Assume that the like crosses the box. – Boby Aug 13 '14 at 18:59
  • Your answer cannot be correct. For the line $y=x$, where $b=0$ and $m=1$, your formula gives $4$, and for $y=\frac{1}{2}x + \frac{1}{2}$, where the correct answer is $1$, it gives $\frac{25}{8}$. – rogerl Aug 13 '14 at 19:06
  • @rogerl $b$ is strictly greater than $0$. – Jam Aug 13 '14 at 19:08
  • @EulCan My bad. But my second example is still correct. – rogerl Aug 13 '14 at 19:09

3 Answers3

2

One possible case could happen while assuming the line intersects the box as follows:

enter image description here

I think, it is not difficult to find the values of $x_A$ and $y_B$ and then find that area.

Mikasa
  • 67,374
  • 1
    Tiny thing but I'd like to point out that if the asker does in fact need $y=mx+mb$ as they implied & not $mx+b$, all they need to to is replace $b$ with $mb$ in Babak's drawing. – Jam Aug 13 '14 at 19:15
  • @EulCan: Oh sorry! I am used to write y=mx+b. Yes you are right. Thanks – Mikasa Aug 13 '14 at 19:17
  • No need to apologise :) but it seems like a notational slipup on the asker's account. – Jam Aug 13 '14 at 19:18
2

Whether you actually get a triangle depends on which of the points $(1,1)$ and $(-1,-1)$ lies above the box or below. So to distinguish these cases, let's see when these points lie on the line.

\begin{align*} (1,1)&:& 1=m(b+1)&\implies m+mb=1 \implies b=\frac1m-1 \\ (-1,-1)&:& -1=m(b-1)&\implies m-mb=1 \implies b=1-\frac1m \end{align*}

So now you can distinguish four cases:

  1. $0<m<1,\quad 0<b<\frac1m-1,\quad (1,1)$ lies above and $(-1,-1)$ lies below the line
  2. $0<m<1,\quad \frac1m-1<b<\infty,\quad (1,1)$ lies below and $(-1,-1)$ lies below the line
  3. $1<m<\infty,\quad0<b<1-\frac1m,\quad (1,1)$ lies below and $(-1,-1)$ lies above the line
  4. $1<m<\infty,\quad1-\frac1m<b<\infty,\quad (1,1)$ lies below and $(-1,-1)$ lies below the line

As you can see, there are two of these four cases where the two mentioned corners both lie below the line, so that the line actually cuts away a triangle as opposed to a right trapezoid. Its one corner is $(-1,1)$, the other two can be computed as

\begin{align*} x&=-1 & y&=m(b-1) & 1-y&=1-m(b-1) \\ y&=1 & x&=\frac1m-b & 1+x&=1+\frac1m-b \end{align*}

The last column lists the legs of the right triangle cut from your square. Multiply these and divide by two to get the area:

$$A=\frac12\biggl(1-m(b-1)\biggr)\biggl(1+\frac1m-b\biggr)$$

This is almost the formula you mention in your question, except for order (which does not matter), a change of sign and the $\frac12$ in front.

MvG
  • 42,596
0

The box that is defined by coordinates $(1,1), (-1,1), (-1,-1), (1,-1)$ is the following:

enter image description here

To draw also the line $y=m(x+b) $ :

For $x=-1: y=m(-1+b)$

For $y=1: x=\frac{1}{m}-b$

Let's suppose that the line intersects the box as followed:

enter image description here

So we want to find the area of the yellow region.

$A(-1,1), B(\frac{1}{m}-b,1), C(-1, m(-1+b))$

$(AB)=\sqrt{(1-1)^2+(\frac{1}{m}-b+1)^2}=\frac{1}{m}-b+1$

$(AC)=\sqrt{(m(-1+b)-1)^2+(-1+1)^2}=m(-1+b)-1$

$$\text{ Area }=\frac{1}{2} (AB)(AC)=\frac{1}{2} \left (\frac{1}{m}-b+1 \right ) \left (m(-1+b)-1 \right )$$

Mary Star
  • 13,956
  • 1
    I think the square roots make this look more difficult than it is, but that might just be personal opinion. – MvG Aug 13 '14 at 20:11
  • Is there an other way to calculate the distance between the points $A(x_a,y_a)$ and $B(x_b,y_b)$, without using the formula: $$\sqrt{(y_b-y_a)^2+(x_b-x_a)^2}$$ ?? – Mary Star Aug 13 '14 at 20:21
  • 1
    Well, since in this case the difference in one coordinate direction will always be zero, you can simply take the difference in the other direction. Which is what your computations come up with, but what I'd have written directly. – MvG Aug 14 '14 at 00:05