# Is there any equation for triangle?

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$:

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

• It looks like this creates isosceles triangles only. Do you have a version that creates other types? – abiessu Oct 29 '13 at 18:59
• You may perhaps do this using polar coordinates. – Lord Soth Oct 29 '13 at 19:00
• A triangle is not a function, so you need to more specific about what exactly you want to do. – copper.hat Oct 29 '13 at 19:01
• @abiessu yeah, I also created a right triangle version – Alon Gubkin Oct 29 '13 at 20:33

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.

• Hey, I started learning vectors in school just last week, how can you do $x-a$ when $x$ is a scalar and $a$ is a vector? – Alon Gubkin Oct 29 '13 at 21:02
• @AlonGubkin: $x$ and $a$ are both vectors. – Henning Makholm Oct 29 '13 at 21:02

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 )$$
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 .

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.

• Given side lengths $a,b,c$, one may come up with a unique equation that describes a triangle, up to translation and rotation (Note that you have a similar situation in a circle, or parabola). So, even though I see your point, I am not comfortable with the message it conveys. – Lord Soth Oct 29 '13 at 19:06
• I am not implying that there is no equation possible for some specific triangle. (Or for any other polygon for that matter). Of course, by using piecewise functions, you can describe ANY triangle in the xy plane. So equations in that respect are certainly possible. I am just not aware of a standardized equation for a triangle, like we have for the circle, parabola, etc. – imranfat Oct 30 '13 at 0:44

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$.

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$.

• Please try to use Latex to help all to understand what do you mean – Semsem Jan 30 '14 at 5:59