I'm interested in finding the unsigned area under a line segment with respect to $y=0$. The line segment is defined by start point $(s_x, s_y)$ and end point $(e_x, e_y)$
Without loss of generality, I translate the line segment along the $x$-axis, equating $s_x$ to $0$ and decreasing $e_x$ by $s_x$. The line equation then becomes:
$$l(x) = \frac{\textrm{rise}}{\textrm{run}}x + y\textrm{-intercept} = \frac{e_y-s_y}{e_x}x + s_y$$
In order to find the unsigned area under the curve, I take the definite integral of the absolute value of $l$:
$$A = \int_{0}^{e_x} |l(x)| dx = \int_{0}^{e_x} \left \lvert \frac{e_y-s_y}{e_x}x + s_y \right \rvert dx$$
I used an online tool (https://www.integral-calculator.com/, I believe it uses Maxima) to evaluate this integral (Wolfram Alpha was unable to compute it for free), and it evaluates to:
$$A = \frac{(e_y|e_y|-s_y|s_y|)e_x}{2(e_y-s_y)}$$
I've checked the answer for several values and this formula seems to be correct for all combinations of sign for the variables.
Now comes my problem. This formula has a discontinuity at $e_y = s_y$, which requires me to make this formula conditional. I can remove the discontintuity as follows:
If $e_y = s_y \neq 0$, the expression becomes:
$$A = \frac{(e_y^2-s_y^2)e_x}{2(e_y-s_y)}=\frac{(e_y-s_y)(e_y+s_y)e_x}{2(e_y-s_y)}=\frac{(e_y+s_y)e_x}{2}$$
which is just the familiar formula for the area of a quadrilateral.
My questions:
- Is there an unconditional expression which covers all cases?
- The formula is commutative in $e_y$ and $s_y$ (i.e. $A(e_y, s_y) = A(s_y, e_y)$ for all $e_x$). I would therefore suspect that this formula can be expressed by commutative operators (e.g. summation and multiplication). This conjecture is proven above for the case where $e_y$ and $s_y$ are of the same sign. Is this correct for the general problem?