Google Answers Logo
View Question
 
Q: Formula to calculate the coordinates of third vertex of right triangle ( Answered 5 out of 5 stars,   2 Comments )
Question  
Subject: Formula to calculate the coordinates of third vertex of right triangle
Category: Science > Math
Asked by: catohara-ga
List Price: $40.00
Posted: 25 Oct 2004 11:49 PDT
Expires: 24 Nov 2004 10:49 PST
Question ID: 419874
I am trying to locate 2 formulas that will help me calculate the
coordinates of the third vertex of a right triangle.

I know the x,y coordinates of the other two vertices, I have the
length of  2 sides of the triangle and by Pythagorean?s theorem, I can
calculate the third.  I feel I should know how to calculate this last
point, but can?t seem to do it (it?s been too long!).

I would like to find 2 formulas that I can use in my code, one that
will give me the x and then one that will give me the y of the third
point.

So for example if this is my triangle :
     
                                (x,y)
				  |\
				A | \ B
				  |  \
				  |___\
			     (4,3)  C  (10,3)

What is the formula(s) to calculate (x,y)? Where A = 3, C = 6 and B =
square root of 45.

It is easy to calculate in your head the (x,y) when sides A & C are
parallel to the 0 x & y axis, but not when they are skewed away from
it.  (I know the answer is this case is (4,6)?)

I have visited sites such as http://mathforum.org and while they have
many formulas, none seem to fit my needs.  I do not have any angles
for any of the vertices, (except the 90 degree one) so Trig formulas
don?t seem very useful.  My problem seems to simple for most math
sites.

I do realize that the formula can have 2 answers, one for the
positive, and one for the negative direction.
Answer  
Subject: Re: Formula to calculate the coordinates of third vertex of right triangle
Answered By: mathtalk-ga on 25 Oct 2004 19:38 PDT
Rated:5 out of 5 stars
 
Hi, catohara-ga:

You list as "given" data:

1) the x,y coordinates of two vertices
2) the lengths of two sides and (by computation) the third length
3) that the triangle is a right triangle

Since there is some overlap in these data, there's also a possibility
of inconsistency.  To avoid this and pick the simplest path to a
solution, let's restrict the data that we need to use to the bare
amount!

Often one labels the vertices of a triangle with capital letters A,B,C
and the opposite edges with lowercase a,b,c.  However you've already
labelled the edges with the capital letters, so let's continue in that
vein and label the opposite vertices with lowercase letters,
respectively.

We are given the coordinates of two vertices, a and b, and between
them is one leg C of a right triangle.  There will be a right angle at
b, and the length of the hypotenuse B, extending from a to c, is
known.  We are asked to find the coordinates of point c from these
"given data".

Provided B is longer than C (whose length is given by the distance
formula based on coordinates for points a and b), a pair of solutions
will exist in the Cartesian plane for point c that produces the
desired right triangle.

[The solution is simplest if we reduce to the case that b is the
origin (0,0).  This reduction is just a matter of subtracting the
coordinates of b from every vertex in the problem.  At the end we
would add the original coordinates of b back and get the answer in
terms of your original coordinates.  However I will go through the
solution without this shortcut for the sake of clarity.]

Let (x_a,y_a) be the coordinates of a, and let (x_b,y_b) be the
coordinates of b.  A path from point b to point a would have this
direction:

  [ x_a - x_b, y_a - y_b ]

In the example you gave, this direction would be the vector [6,0], but
this direction can be computed whenever the coordinates of points a
and b are given.

The direction from b to c (which contains the other "leg" of the right
triangle and is therefore perpendicular to the first direction) could
go in either of two directions (giving us the expected two solutions).

To find one of these perpendicular directions, switch the order of the
coordinates from the first direction and change the sign of one of
them.  For example, we might calculate for the example case:

  [6,0] --> (switch) [0,6]
        --> (change sign of one coordinate) [0,-6]

Now if that is one perpendicular direction, then an opposite
perpendicular direction would be obtained if we'd changed instead the
other coordinate's sign, giving e.g. [-0,+6].  Note that these two
choices are always additive inverses of each other:

  [0,-6] + [0,+6] = [0,0]

It doesn't matter which one you happen to choose; either will give us
both solutions in the end.

Now we want to take the chosen perpendicular direction and scale it to
unit length.  Let's say the perpendicular direction we will work with
is this one:

  [ y(a) - y(b), x(b) - x(a) ]

If we calculate its length, the length turns out to be the same as the
distance C between a and b.  So I'm going to label the unit
perpendicular vector:

   U = (1/C) [ y(a) - y(b), x(b) - x(a) ]

                y(a) - y(b)     x(b) - x(a)
     =     [   ------------- , -------------   ]
                     C               C

We are about to finish!  Using the Pythagorean formula, we know how
far point c is from "right corner" point b in this direction, namely:

   A  =  (plus or minus) SQRT( B^2 - C^2 )

Remember that C was the length of one leg, and B the length of the
hypotenuse.  Therefore we only need to add a multiple A of the unit
vector u to the coordinates of b in order to obtain c:

  ( x_c, y_c )   =   coordinates of c

                 =  ( x_b, y_b ) +  A * u

                             A*(y(a)-y(b))         A*(x(b)-x(a))
                 =   [ x_b + ------------- , y_b + ------------- ]
                                 C                        C

Let's apply this to your example situation.  Then for A = +3:

  ( x_b, y_b )   =  (4,3)

  ( x_c, y_c )   =  (4,3)  +  3 * u

                 =  (4,3)  +  [ (3*0)/6 , (3*(-6))/6 ]

                 =  (4,3)  +  [ 0, -3 ]

                 =  (4,0)

On the other hand if we had taken A = -3, we'd get the point c lying
in the opposite direction:

  ( x_c, y_c )   =  (4,3)  +  [ 0, +3 ]

                 =  (4,6)

as you know, of course.  [Similarly if we'd chosen u = [0,1] instead
of [0,-1], we get both solutions but in the other order with respect
to plus or minus A.]

There is a slightly more general problem you might be interested in
knowing how to solve, but I didn't want to clutter up this Answer with
a "tangent".  Let me know if further clarification would be helpful.

regards, mathtalk-ga

Clarification of Answer by mathtalk-ga on 25 Oct 2004 19:42 PDT
Here's a modified diagram of the triangle for convenient reference:
     
                                  c
				  |\
				A | \ B
				  |  \
				  |___\
			         b  C  a

where a = (x_a,y_a), b = (x_b,y_b) are given along with the length of
the hypotenuse B.

regards, mathtalk-ga
catohara-ga rated this answer:5 out of 5 stars and gave an additional tip of: $8.00
Thank you for you're help.  It appears to be exactly what I was looking for.

Comments  
Subject: Re: Formula to calculate the coordinates of third vertex of right triangle
From: ticbol-ga on 26 Oct 2004 05:34 PDT
 
A) If the legs are parallel to the x,y axes.
Say the right triangle is ABC, where vertex B is at the right angle,
vertex A is above or below B, and vertex C is to the left or to the
right of B.
So AB is vertical and BC is horizontal.

You said the lengths of two sides are known. Which two sides? Say the
two legs. So the hypotenuse is not given, although its length can
easily be solved by the Pythagorean theorem. Say AB = U long and BC =
V long.
----------
Case A.1: If (x,y) is B.
Then A and C are given. Since their coordinates are known, say A is
(a,b) and C is (c,d).

By examination,
x = a, and y = d
Therefore, (x,y) = (a,d)

-------------
Case A.2: If (x,y) is A. 
Then B and C are known. Say B is (e,f) and C is (c,d).

By examination, x = e.
That makes A to be (e,y). So only y is unknown.

Distance formula, d = sqrt[(x2 -x1)^2 +(y2 -y1)^2].
So, hypotenuse AC = sqrt[(e-c)^2 +(y-d)^2]

In rt. triangle ABC, by Pythagorean theorem,
(AB)^2 +(BC)^2 = (AC)^2
Substitutions,
U^2 +V^2 = (e-c)^2 +(y-d)^2  ----(1)
That is a quadratic equation where the only unknown is y.
(y-d)^2 = U^2 +V^2 -(e-c)^2
Therefore, y = d +,-sqrt[U^2 +V^2 -(e-c)^2]  ----two possible y's.

+,- is "plus or minus"

-------------
Case A.3: If (x,y) is C. 
Then A and B are known. Say A is (a,b) and B is (e,f).

By examination, y = f
That makes C to be (x,f). So only x is unknown.

hypotenuse AC = sqrt[(x-a)^2 +(f-b)^2]

In rt. triangle ABC, 
(AB)^2 +(BC)^2 = (AC)^2
Substitutions,
U^2 +V^2 = (x-a)^2 +(f-b)^2  ----(2)
Therefore, x = a +,-sqrt[U^2 +V^2 -(f-b)^2]  ----two possible x's.

=======================================================================
B) If the legs AB and AC are not parallel to the x,y axes. Their are
skewed, as you say.

Same rt. triangle ABC as above.

Only one case example here, because whichever vertex is (x,y), the
solution should be the same way.

Say,
vertex A is (x,y).
then B = (e,f) and C = (c,d)
and AB = U and BC = V 

By distance formula,
(AB)^2 = U^2 = (x-e)^2 +(y-f)^2  -----(3)
(BC)^2 = V^2 = (e-c)^2 +(f-d)^2  -----(4)
(AC)^2 = (x-c)^2 +(y-d)^2  ----------(5)

In rt. triangle ABC, by Pythagorean theorem,
(AB)^2 +(BC)^2 = (AC)^2
Substitutions,
{(x-e)^2 +(y-f)^2} +{(e-c)^2 +(f-d)^2} = (x-c)^2 +(y-d)^2
Simplify that and you should arrive at
x(e-c) +y(f-d) = e^2 +f^2 -ec -fd  ----(6)

Then,
x = (e^2 +f^2 -ec -fd -y(f-d)) / (e-c)   -----(6a)
Or,
y = (e^2 +f^2 -ec -fd -x(e-c)) / (f-d)   -----(6b)

Then go back to Eq.(3).
Plug in y, by using (6b), and you'd get x.

Then go back to Eq.(5).
Plug in x, by using (6a), and you'd get y.

(I did not go in those. Too long. For free, this is good enough.)
Subject: Re: Formula to calculate the coordinates of third vertex of right triangle
From: ticbol-ga on 27 Oct 2004 00:15 PDT
 
Zeez, this morning on my way to work, I thought of these:

---------
Case A.2: If (x,y) is A. 
Then B and C are known. Say B is (e,f) and C is (c,d).

By examination, x = e.
That makes A to be (e,y). So only y is unknown.

But AB is given as U.
Therefore, without computation, y = f+U.
And (x,y) is (e,f+U).

---------
Case A.3: If (x,y) is C. 
Then A and B are known. Say A is (a,b) and B is (e,f).

By examination, y = f
That makes C to be (x,f). So only x is unknown.

But BC is given as V.
Therefore, x = e+V
And (x,y) is (e+V,f).

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy