Equation of a Triangle

 

An ellipse can be expressed as the locus of points with orthogonal coordinates (x,y) such that (x/a)2 + (y/b)2 = 1 for some constants a,b.  However, it's more difficult to give a succinct description of a piece-wise linear curve, e.g., a triangle.  We seek a function f() such that f(x,y) = 0 if and only if the point (x,y) is on the perimeter of a given triangle.  It's not hard to see that no such function exists if we restrict ourselves to functions definable in terms of a finite number of basic arithmetical operations, i.e., additions, subtractions, multiplications, and divisions.

 

This raises the question of what other operation could be adjoined to the four basic operations that would enable us to define a general polygon.  One possibility is the familiar "absolute value" function, defined as

 

 

This function permits us to express a square as |x| + |y| = 1.  More general quadrilaterals can be expressed in the form

 

 

where A > B and C > D. Two of the four vertices of this quadrilateral are on the x axis at the points x = -1/(A-B) and x = 1/(A+B), while the other two are on the y axis at the points y = -1/(C-D) and y = 1/(C+D).  This nearly enables us to define a triangle by setting one of these vertices to zero; we can come arbitrarily close to zero using finite coefficients, but we can't quite define a true triangle.

 

A brute force approach would be to define three rays through the origin of the coordinate system:

 

 

These divide the plane into six regions.  We can then construct a function that reduces to one of three lines, depending on the region. The point (x,y) is above or below the line y = ax depending on whether the sign of y - ax is positive or negative.  Therefore, a Boolean variable indicating whether (x,y) is above the line y = ax can be expressed as

 

 

Obviously the complement of this function

 

 

is a Boolean variable indicating whether (x,y) is below the line y = ax. However, these functions are undefined for points on the line, because then |y - ax| = 0.  One way of removing this ambiguity is to express Q and q in terms of a function that is arguably even simpler than the absolute value, namely, the sign function

 

 

With this function we can define Q and q as

 

 

where now Q signifies that (x,y) is above or on the line y = ax.

 

Using these Boolean operators we can construct a function that reduces at any given point to the equation of one of the three edge lines of a triangle, depending on the relation of that point to the other two edge lines.  For example, consider a triangle whose vertices fall on the three rays shown below

 

 

The edge line connecting the vertices on rays a and b should be invoked whenever (x,y) is on or above the ray lines a and b.  The edge line connecting a and c should be invoked when (x,y) is below both of the ray lines a and c.  The edge line connecting b and c should be invoked when (x,y) is on or above ray line c and below ray line b.  Thus, if the equations for the individual edge lines are A1x + B1y = 1, A2x + B2y = 1, and A3x + B3y = 1, then the overall equation for the triangle can be expressed in the form

 

 

To illustrate, if we take the triangle given by the rays

 

 

with the edge lines

 

 

then equation (1) is satisfied by the points on the perimeter of the triangle shown below.

 

 

This figure assumes we have defined Q and q in terms of the "sign" function.  Another way of dealing with the singularity of the absolute value versions of Q and q would be to multiply through equation (1) by the factor 4|y - ax||y - bx||y - cx|.  Letting R,S,T and r,s,t denote respectively the values and the absolute values of y - ax, y - bx, and y - cx, this gives the non-singular function

 

 

This is equivalent to (1) except that it is also satisfied by the points on any of the three rays.  Thus the solution of equation (2) is as illustrated below.

 

 

One interesting aspect of this "triangle function" is that we don't need to restrict our attention to just the points (x,y) that satisfy the equation.  Instead, we can assign a color to every point on the plane depending on how close it comes to satisfying the equation. This results in some striking images, such as the "stealth fighter" shown below.

 

 

Return to MathPages Main Menu