# Thread: [RESOLVED] Right Triangle Solve for 3rd Point Coordinate

1. ## [RESOLVED] Right Triangle Solve for 3rd Point Coordinate

This problem has been giving me a headache, and I need it for my collision code I'm writing, and all the right triangle stuff on Google has been mainly all solving for sides and angles or missing variables in the coordinates themselves. But programmably, given 2 coordinate points in 2D in a right triangle, how do I solve for the 3rd coordinate?

[EDIT] Forgot to add I have a known angle too.

2. ## Re: Right Triangle Solve for 3rd Point Coordinate

I haven't given it too much thought, but it should be simple... with a right triangle, you have three known angles, a 90, and two 45s. If you normalize the 90 angle at 0, and mark it with x0,y0... and mark the upper angle with x1,y1 and give it the coordinate of 0,1, the lower right coordinate becomes x2,y2 with a coordinate of 1,0 ... you'll see that this pattern repeats... no matter what the coordinate is for x0,y0, the coordinate for x2,y2 is simply the flipped values of x1,y1 such that x2=y1 and y2=x1.

Maybe... that works for right triangles that are perfectly flat... I didn't take into consideration rotation of any kind... and I don't have graph paper to try it out... dang... I may have just gotten that all wrong... in fact, I'm sure I have... never mind.

-tg

3. ## Re: Right Triangle Solve for 3rd Point Coordinate

Since you need two sides and an angle, or two angles and a side, given only two coordinates, which gives you one side, I have to assume the side given is the hypotenuse of the right triangle. Given the hypotenuse and one of the angles (not the right one of course), then you know the other angle so have the two angles and a side necessary to calculate the origin.

The issue is which angle are you giving, what is your convention? Assuming angle B, and C are not equal, then you have four possible coordinates for the third point of the right triangle, two if you're giving angle B, and two if you're giving angle C. The two coordinates in each case are the third point reflected across the hypotenuse.

I think the least computational approach would be calculating the intersection of the two rays from each of those points.

p.s. I guess the two coordinates don't have to define the hypotenuse, If they define one leg, and you know that, then you know the other angles and can determine the size of other legs and coordinates. But you still need to know what side of the triangle the two coordinates represent, and assuming the angle is the one at the end of the leg, (assuming second coordinate is the end of the leg), then you still need the convention of whether you're talking clockwise or counterclockwise angle convention because you still have two points (the reflection across the leg) for an answer.

4. ## Re: Right Triangle Solve for 3rd Point Coordinate

Originally Posted by techgnome
I haven't given it too much thought, but it should be simple... with a right triangle, you have three known angles, a 90, and two 45s. If you normalize the 90 angle at 0, and mark it with x0,y0... and mark the upper angle with x1,y1 and give it the coordinate of 0,1, the lower right coordinate becomes x2,y2 with a coordinate of 1,0 ... you'll see that this pattern repeats... no matter what the coordinate is for x0,y0, the coordinate for x2,y2 is simply the flipped values of x1,y1 such that x2=y1 and y2=x1.

Maybe... that works for right triangles that are perfectly flat... I didn't take into consideration rotation of any kind... and I don't have graph paper to try it out... dang... I may have just gotten that all wrong... in fact, I'm sure I have... never mind.

-tg
The problem is, is that the right triangle is not gonna be 45 45 and 90. You have 90 since its a right triangle, another angle which can literally be anything, and 2 known 2d coordinates. The reason why this particular angle is known is because it is against a line segment that the ball collided into. So my known 2 points are the balls position, and the predicted collision point. For me to get the length of this side, I can do the distance formula. Sqrt(x2- x1)^2 + (y2-y1)^2). Now i know the length of the side. The line segment it collided into has a direction its facing, kind of a reverse perpendicular normal of the line segment, which i can use to multiply to this side. And believe it or not, this now gives me the length of side 2! Doing an arccos(b/c) * 180/PI to the 2 known sides now gives me the angle of those 2 sides. Now given that, how do i get the 3rd coordinate point?

5. ## Re: Right Triangle Solve for 3rd Point Coordinate

Nevermind. I figured it out!

Take any 2d coordinate. And take the side that coorispondes with that coordinate thats in between the unknown point and the known point. Multiply the normalized segment direction by that particular side, and add it to the known coordinate. Youll end up with the answer! It works. Thanks for trying though.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured