In algebra and geometry, straight lines are commonly written in a parametric form. That is, instead of writing, say, y = mx + b, they would instead be written as x = t, y = mt + b. At first glance, this appears to be nothing but a pointless variable substitution, but it does have a few benefits.
The former form, known as explicit form, allows you to very easily determine whether a given point is or is not on the line: just drop the value of x and y in place and crunch the numbers, and check them for equality. The latter, parametric form allows you instead to very easily generate points on the line by picking a value for the parameter t, and then crunching the numbers.
The other advantage of a parameteric representation is that it can cover cases that the explicit form cannot. The canonical example of this is a vertical line in the standard 2D cartesian coordinate system. This line has an 'infinite' slope, and so cannot be written in the form y = mx + b. The parameteric form, however, is trivially written down as x = bx and y = t, where bx is the value of the x-intercept of the line.
Give two non-equal points A and B, the straight line connecting these points is easy to parameterize:
x = (Bx - Ax)t + Ax
y = (By - Ay)t + Ay
Under this parameterization, setting t = 0 gives you back the point A, and setting t = 1 gives you back the point B. If you want different values of t to map to the original points, then a suitable linear transformation of t will suit your needs.
As an exercise for the reader: give the parameteric equation of the line between points A and B where t = -1 maps to point A and t = 1 maps to point B. (Hint: if your equations are right, then T = 0 will map to the point halfway through the two points.)
In this post, we will instead be interested in a different line: the bisector of these two points, or, the line for which every point on the line is the same distance from both points. The standard distance between two points A and B is given by sqrt[(Ax - Bx)2 + (Ay - By)2], and is known as the Euclidean norm. Other norms exist (the Manhattan norm and the Chebyshev norm being the two most famous examples), but they will not be considered further here.
Since points on the bisector are equidistant from the two points A and B, that is as good a place as any to start looking for a parameterization:
sqrt[(X - Ax)2 + (Y - Ay)2] = sqrt[(X - Bx)2 + (Y - By)2]
Apply a liberal dose of algebra:
(X - Ax)2 + (Y - Ay)2 = (X - Bx)2 + (Y - By)2
X2 - 2AxX + Ax2 + Y2 - 2AyY + Ay2 = X2 - 2BxX + Bx2 + Y2 - 2ByY + By2
Ax2 + Ay2 - 2AxX - 2AyY = Bx2 + By2 - 2BxX - 2ByY
Ax2 - Bx2 + 2BxX - 2AxX = By2 - Ay2 + 2AyY - 2ByY
Ax2 - Bx2 + 2(Bx - Ax)X = By2 - Ay2 + 2(Ay - By)Y
At this point, we will examine the behaviour of this equation. If Ax = Bx, then the left side of the equation equals zero, and we eventually get that Y = (Ay + By) / 2. We can then set X = t, since whatever value it is gets multiplied by zero anyway and will not alter the value of the equation. If Ay = By, then we get a similar result: the right side of the equation equals zero, yielding X = (Ax + Bx) / 2, allowing us to set Y = t.
The point here is that if the points lie on the same horizontal line, then their bisector is a vertical line halfway between them, and if the points lie on the same vertical line, then their bisector is a horizontal line halfway between them. This result is pretty obvious when you think about the problem we are solving, so it is good that we didn't get a different result.
If both Ax = Bx and Ay = By, then the two points are identical. The parameteric line we get is X = s, Y = t; basically saying that EVERY point is the same distance from the two points, because they are the same point. This isn't a line, though, so we will add a precondition that this case is not allowed.
Let us now consider the case where the points have different x and y coordinates. To parameterize the line, we will simply set the equation above equal to a new parameter t:
Ax2 - Bx2 + 2(Bx - Ax)X = t = By2 - Ay2 + 2(Ay - By)Y
This will allow us to solve for X and Y in terms of t:
Ax2 - Bx2 + 2(Bx - Ax)X = t 2(Bx - Ax)X = t + Bx2 - Ax2 2(Bx - Ax)X = t + (Bx - Ax)(Bx + Ax) X = t / 2(Bx - Ax) + (Bx + Ax) / 2 X = [(Ax + Bx) / 2] - [t / 2(Ax - Bx)] |
By2 - Ay2 + 2(Ay - By)Y = t 2(Ay - By)Y = t + Ay2 - By2 2(Ay - By)Y = t + (Ay - By)(Ay + By) Y = t / 2(Ay - By) + (Ay + By) / 2 Y = [(Ay + By) / 2] + [t / 2(Ay - By)] |
To summarize: given two distinct points A and B, the bisector line between them has parametric form:
X = [(Ax + Bx) / 2] - [t / 2(Ax - Bx)]
Y = [(Ay + By) / 2] + [t / 2(Ay - By)]
These equations have a pleasant symmetry, except that one has a subtraction while the other has an addition. You can swap the subtraction if you wish; setting t = -u will do nicely. Note that when t = 0, these equations give the point halfway between A and B, as expected.
No comments:
Post a Comment