Is there any equation for triangle?

74.1k Views Asked by At

Like there's an equation of a circle, is there any equation of a triangle?


I've been trying to build one and the closest thing I've managed to do is to create an equation of 2 lines and use the $x$ axis as the 3rd side of the triangle.

Here's how I built the two lines equation:

Let $m$ be the slope of the first line, $-m$ is the slope of the second line, and $a$ is the x-value of their intersection point.

The first thing we need to do is to find the y-intercept of the second line. Let's call it $p$. The first line equation is $y=mx$ and the second line equation is $y=-mx+p$

$ma=-ma+p$

$p=2ma$

So we need to build an equation that equals to $y=mx+n$ when $x<a$ and to $y=-mx+2ma$ when $x>a$. First lets handle the slope. It should be $m$ when $x<a$ and $-m$ when $x>a$.

This can be achieved by:

$\dfrac {a-x} {|a-x|} m$

The y-intercept of the final equation should be $0$ when $x<a$ and $2ma$ when $x>a$.

This can be achieved by:

$(\dfrac {x-a} {|a-x|} + 1)*2ma$

So our equation looks like:

$y=\dfrac {a-x} {|a-x|} mx+(\dfrac {x-a} {|a-x|} + 1)*2ma$

Simplified:

$y=\dfrac {-m(x-a)^2} {|a-x|} + ma$

Or:

$y=m(x-a)sgn(a-x)+ma$

Plot $m=2, a=5$:

enter image description here


So is there any way to build an equation for triangle without using the $x$ axis as the 3rd side of the triangle?

6

There are 6 best solutions below

2
On

There is no standard equation for a triangle, like there is for a circle, parabola or ellipse. The reason is that the circle for example has a clear classic geometric definition: A locus of points. It would be something like "The collection of points that have a fixed distance to a given point". From such a definition one would use the distance formula to arrive at an algebraic equation. The circle, ellipse, parabola and hyperbola all have such classic definitions (they are conic sections) and hence a set of standard equations. A triangle does not fall in that category at all. There is no classic definition for a "collection of points" that uniquely describes a triangle.

2
On

If you really, really want a single equation that defines a triangle, you could make one by a trick such as

$$ \big(|x-a|+|x-b|-|a-b|\big) \big(|x-b|+|x-c|-|b-c|\big) \big(|x-c|+|x-a|-|c-a|\big)=0 $$

where $x$ is the unknown and $a, b, c$ are the corners of the triangle, all being vectors.

However, such an equation won't in particular help you understand the triangle, nor will it be very helpful for reasoning about it or calculating things about it. In just about every conceivable application, a different representation of the triangle than an equation will be more useful.

0
On

Triangle $A$ with points $x, y, z \in \Bbb{R}^2$ is the boundary of the convex set containing the points or the set of all $w = ax + by + cz, \ \ a + b + c = 1, \ a,b,c \geq 0$. Leting $S$ be that convex set, then $A = \partial S$, the boundary of $S$.

0
On

Some "closed" expressions for the triangle are quite useful, as is obvious from the following web page: Efficient 2-D & 3-D Point Probes.

The gist of the method is the so-called isoparametric ("same parameters") transformation, where "isoparametric" is a terminology which is quite common in Finite Element contexts. An elaborate explanation of it has been given, as an answer to the following MSE question: Converting triangles to isosceles, equilateral or right???

The formulas which express the local coordinates $\xi$ and $\eta$ into the global coordinates $x$ and $y$ are repeated here for convenience: $$ \begin{array}{ll} \xi = [ (y_3 - y_1).(x - x_1) - (x_3 - x_1).(y - y_1) ]/\Delta \\ \eta = [ (x_2 - x_1).(y - y_1) - (y_2 - y_1).(x - x_1) ]/\Delta \end{array} $$ Here $\Delta$ is the determinant of the inverse transformation.
With the above, the "closed" triangle equation $T(x,y) = 0$ is simply given with: $$ T(x,y) = \min( \xi , \eta , 1 - \xi - \eta )$$ enter image description here
The maximum of the function $T$ is reached for $\xi = \eta = 1 - \xi - \eta = 1/3$ , hence at the midpoint (barycenter) of the triangle. If we draw straight lines from the midpoint towards the vertices, and further, then the whole plane is subdivided into three regions, one where $T(x,y) = \xi$ , one where $T(x,y) = \eta$ and one where $ T(x,y) = 1 - \xi - \eta$ . Our "inside/outside" function $T$ is zero at the triangle sides, positive inside and negative outside. It's shaped like a mountain with top $1/3$ at the midpoint and three sharply edged slopes downhill. The contour lines of this function are triangles, where the contour line with height $0$ is the original triangle itself. ( Quite the same is the case with the equation of e.g. a circle: $C(x,y) = 0$ with $C(x,y) = R^2 - (x-a)^2 - (y-b)^2$. )

A generalization of the linear triangle in 2-D to a linear tetrahedron in 3-D is given in the following answer : Computing a three-dimensional Lebesgue measure of a bounded set .

1
On

Building off of Alon Gubkin's formula, you can simply:

$am+m(-a+t)\text{sgn}(a-t) = m(a-\left|a-t\right|)$

assuming $a > 0$ and $m > 0$ and $t > 0$.

0
On

The equation can be constructed as follows.

Suppose three linear equations define the sides of the triangle:

  • $f_1(x,y)=0$
  • $f_2(x,y)=0$
  • $f_3(x,y)=0$

The functions can be written in two ways, differing by their signs. Example $x-y=0$ and $y-x=0$ both define the same line. For $f_1$, $f_2$ and $f_3$ we select the variant such that the center point (actually any point inside the triangle) is negative, i.e. $f_i(c_x, c_y)<0$.

The triangle equation is then: $$max(f1(x, y), f2(x, y), f3(x, y))=0$$

Because all $f_i$ are negative (by construction) inside, at least one $f_i$ has to be positive on the outside. The $max$ returns a positive number outside, a negative number inside, and therefore must be $0$ on the triangle itself.

Example:

The triangle with corners at $A=[-2,3]$, $B=[-4,-4]$ $C=[5,2]$ is bounded by the lines:

  • $f1(x,y) = -19/7+x/7+y=0$
  • $f2(x,y) = 2/3x-4/3-y=0$
  • $f3(x,y) = -7/2x-10+y=0$

The triangle equation is: $$max(-19/7+x/7+y, 2/3x-4/3-y, -7/2x-10+y)=0$$

Plot:

https://www.desmos.com/calculator/wjdyovcwci