Main Page | Report Page

 

  Computers Forum Index » Computer - Graphics (Algorithms) » Calculate third point of a triangle, given two points

Author Message
Philbo
Posted: Fri Nov 05, 2004 7:37 pm
 
In an equilateral triangle ABC, I've the the coordinates of two of the
points (A and B).

Is it possible to calculate the coordinates of the third (C)? I've
tried using pythagoras's theorem but this only seems to work when one
of the triangle sides are parallel to an axis.

Alternativly (I dont know whether this is easier or not) calculate
coordinates of B and C given the points A and M, where M is the
midpoint of BC.

Any help or links to helpful threads appriciated.

Philbo
 
Keith A. Lewis
Posted: Fri Nov 05, 2004 7:37 pm
 
philbo@gmail.com (Philbo) writes in article <ae942a99.0411050848.1af0bb7a@posting.google.com> dated 5 Nov 2004 08:48:23 -0800:
Quote:
In an equilateral triangle ABC, I've the the coordinates of two of the
points (A and B).

Is it possible to calculate the coordinates of the third (C)? I've
tried using pythagoras's theorem but this only seems to work when one
of the triangle sides are parallel to an axis.

Assuming you're working in only 2 dimensions, you will have 2 possible
points C, one on each side of AB. 3 dimensions gives you a circle of
possible points...

Quote:
Alternativly (I dont know whether this is easier or not) calculate
coordinates of B and C given the points A and M, where M is the
midpoint of BC.

That is more definative (again assuming 2 dimensions) -- you'll know exactly
where B and C are once you have A and M. Vectors MB and MC will be
perpendicular to AM, in opposite directions, with magnitude 1/sqrt(3) * |AM|.

--Keith Lewis klewis {at} mitre.org
The above may not (yet) represent the opinions of my employer.
 
Sylvain Croussette
Posted: Fri Nov 05, 2004 7:37 pm
 
philbo@gmail.com (Philbo) dixit:

Quote:
In an equilateral triangle ABC, I've the the coordinates of two of the
points (A and B).

Is it possible to calculate the coordinates of the third (C)? I've
tried using pythagoras's theorem but this only seems to work when one
of the triangle sides are parallel to an axis.

Alternativly (I dont know whether this is easier or not) calculate
coordinates of B and C given the points A and M, where M is the
midpoint of BC.

Any help or links to helpful threads appriciated.

Philbo

Rotate the vector AB by 60 degrees (clockwise and ccw if you want the
2 possibilities). Then C = A + rotatedAB.
 
Just d' FAQs
Posted: Fri Nov 05, 2004 7:37 pm
 
On 5 Nov 2004 08:48:23 -0800, philbo@gmail.com (Philbo) wrote:
Quote:
In an equilateral triangle ABC, I've the the coordinates of two of the
points (A and B).

Is it possible to calculate the coordinates of the third (C)? I've
tried using pythagoras's theorem but this only seems to work when one
of the triangle sides are parallel to an axis.

Alternativly (I dont know whether this is easier or not) calculate
coordinates of B and C given the points A and M, where M is the
midpoint of BC.

This elementary question seems to call for an elementary answer. (To
keep more advanced readers from being completely bored, however, we
can use some techniques with wider applicability.)


GEOMETRY
You will surely use Pythagoras, though perhaps indirectly. There is a
line of points equidistant from A and B; we know C is on that line
because the triangle is equilateral. However, as we stand at A and
look at B we do not know whether C will be to our right or to our left
side, an ambiguity we cannot resolve without addition information.

If we were solving this geometrically with a ruler and compass instead
of algebraically, we would center the compass on A with radius to B
and draw one circle, then center on B and draw a second; the circles
will intersect in two points, our two choices for C.


ALGEBRA
Intersecting two circles is not so easy with algebra. Instead, we can
use that midpoint, M. The line of equidistant points not only passes
through M, it does so perpendicular to the line from A to B (or to M).
Also, we can easily write an equation to generate points on the line:

P(t) = M + t * perp(M-A)

If the coordinates of M and A are (Mx,My) and (Ax,Ay), then we have

(Px(t),Py(t)) = (Mx+t*(My-Ay),My-t*(Mx-Ax))

There is actually an implicit use of Pythagoras hidden in the formula
for "perp" used to generate this perpendicular bisector. We require a
more explicit use of Pythagoras to compute the distance from A to M,
which we then double to give the radius of a single circle centered on
point A.

r = length(M-A)
= sqrt( (Mx-Ax)^2 + (My-Ay)^2 )

All points on the circle satisfy the implicit equation

0 = (2r)^2 - ( length(P-A) )^2

Since the line intersects the circle in our two candidates for C, we
can substitute our line formula into our circle equation to give a
quadratic equation in t whose two solutions give our C points when
substituted back into the line formula.


ALTERNATIVES
These calculations are straightforward; but we have many alternatives.

For example, we know that in the Euclidean plane the sum of the angles
of a triangle equals 180 degrees, so each angle of an equilateral
triangle is 60 degrees. We can construct a matrix using cos(60)=1/2
and sin(60)=sqrt(3)/2 and use it to rotate the segment from A to B
around A to bring its new end to C.

Or, more cleverly, we can use our perp technique but exploit what we
know must be the ratio of the sides of the right triangle with right
angle at M. That is, we know (up to sign)

t = tan(60)
= (sqrt(3)/2) / (1/2)
= sqrt(3)

This nice thing about this solution is that we can write a closed-form
solution for C in terms of A and M.

/ (Mx+sqrt(3)*(My-Ay),My-sqrt(3)*(Mx-Ax))
(Cx,Cy) = | or
\ (Mx-sqrt(3)*(My-Ay),My+sqrt(3)*(Mx-Ax))


EXAMPLE
One of the legendary figures in computer science, Don Knuth, humbly
wrote to some colleagues about his efforts

"Beware of bugs in the above code; I have only proved it correct,
not tried it."

So let us at least test our theory with a simple example. Suppose A
and B are both on the x axis, at +1 and -1 respectively. Clearly the
midpoint M is at the origin. Using the first formula for C we get

(Cx,Cy) = (0+sqrt(3)*(0-0),0-sqrt(3)(0-1)
= (0,sqrt(3))

As expected, the solution lies on the y axis, and its distance from A
is 2, which is correct. Symmetry tells us (0,-sqrt(3)) should be the
other solution. Verify!


CHALLENGE
It is an instructive exercise to work out the details of the previous
alternatives. That is, explicitly set up the implicit equation in t
and solve it; write out the matrix and vector components needed in the
rotation solution; and for a real challenge intersect the two circles.


SUPPLEMENT
Meanwhile, let us see how Pythagoras is hidden in perp. Suppose vector
v=M-A has components (x1,y1). If vector u=(x2,y2) is added to v, and
if u is truly perpendicular to v, then by the head-tail rule of vector
addition the sum u+v is the hypotenuse of a right triangle with sides
u and v. Therefore it must be the case that the squared length of u+v
minus the squared length of u and minus the squared length of v equals
zero, by Pythagoras. So we compute (using Pythagoras for lengths!)

0 = ((x1+x2)^2 + (y1+y2)^2) - (x1^2 + y1^2) - (x2^2 + y2^2)
= x1^2 + 2x1x2 + x2^2 + y1^2 + 2y1y2 + y2^2
-x1^2 - x2^2 - y1^2 - y2^2
= 2(x1x2 + y1y2)

Notice that we seem to have reinvented the dot product. Furthermore,
given v=(x1,y1) it is clear that u=(x2,y2)=(-y1,x1) is perpendicular,
as is any scalar multiple of this u, such as its negative (y1,-x1). So
we choose

perp (x,y) = (y,-x)

which is a clockwise 90 degree rotation.
 
Philbo
Posted: Sat Nov 06, 2004 7:38 pm
 
Just d' FAQs <nobody-here@mac.com> wrote in message news:<q8dno0lbmpg8lo7f7tavk6ghu08efkmolt@4ax.com>...
Quote:
On 5 Nov 2004 08:48:23 -0800, philbo@gmail.com (Philbo) wrote:
In an equilateral triangle ABC, I've the the coordinates of two of the
points (A and B).

Is it possible to calculate the coordinates of the third (C)? I've
tried using pythagoras's theorem but this only seems to work when one
of the triangle sides are parallel to an axis.

Alternativly (I dont know whether this is easier or not) calculate
coordinates of B and C given the points A and M, where M is the
midpoint of BC.

This elementary question seems to call for an elementary answer. (To
keep more advanced readers from being completely bored, however, we
can use some techniques with wider applicability.)


Oh im sorry, I didn't realise this was a group for maths experts only!
 
Just d' FAQs
Posted: Sat Nov 06, 2004 7:38 pm
 
On 6 Nov 2004 07:43:33 -0800, philbo@gmail.com (Philbo) wrote:
Quote:
This elementary question seems to call for an elementary answer. (To
keep more advanced readers from being completely bored, however, we
can use some techniques with wider applicability.)


Oh im sorry, I didn't realise this was a group for maths experts only!

Quite the contrary; many of our questions come from people who tell us
their mathematics skills are poor. However, we also have many readers
for whom this question about equilateral triangles is trivial. When
responding to a post from someone of unknown expertise we are forced
to guess what kind of answer will be most helpful.

The parenthetical remark relates to my own personal goals. An ideal
response is like a Pixar movie: fun for the whole family. The health
of the newsgroup depends on the interest and participation of those
who know more, such as practitioners, college students, researchers,
and so on. For them, finding a third point of an equilateral triangle
may not be much of a challenge, but intersecting two circles could be.
Also, it can be stimulating to see a problem approached in a variety
of ways, each with its own insights and benefits. It may be overkill
for a simple problem, but good practice for more difficult ones.

Consider the problem of intersecting two circles. As it arises in the
equilateral triangle question, it has some helpful restrictions: the
circles are known to intersect and known to have the same radius. But
we can generalize to different sizes, unsure intersections (including
tangency!), different quadrics, or any two algebraic plane curves.

Experts have an all-purpose tool for intersecting two curves each
given implicitly as polynomials, even ratios of polynomials. In fact,
we know that a curve of degree N intersects a curve of degree M in a
total of M*N points if they have no common components. This is the
famous theorem of Bezout, closely related to the fundamental theorem
of algebra that every polynomial has a root. But it requires us to
consider intersection multiplicity, points at infinity, and complex
coordinates. However, this all falls out automatically when we use our
tool, the resultant. We write the two polynomials in homogeneous form,
arrange the coefficients in a matrix, and take the determinant of that
matrix to generate a single polynomial whose roots reveal the points
of intersection.

We have readers for whom resultants are second nature; but we also
have readers who might struggle to intersect two lines. The challenge
I pose for myself is to engage the former without losing the latter,
because both contribute to the vitality of the group.

Experts and non-experts are both definitely welcome.
 
 
Page 1 of 1    
All times are GMT
The time now is Sat Aug 02, 2014 4:46 am