The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Thread: Calculate the points of an isosceles triangle using the sides

1. 56
posts
Registered User

Calculate the points of an isosceles triangle using the sides

-- edit // I meant to say calculate the 'angles' of an isosceles triangle using the sides (not points) // --

Ok, I'm going to kind of step-by-step this one and post as I come up with new info.

Basically, an isosceles triangle has 2 equal sides and the 3rd side is of a different length and called a hypotenuse. This also means that there are always 2 equal angles and a third angle which is different from the other 2.

I've gotten as far as calculating the length of one of the lines that is the same as the other and using that I can calculate the hypotenuse.

(sameLineLength is the length of my equal lines.)

Code:
`solveIsoscelesHypotenus =  int(Math.sqrt(2*(sameLineLength*sameLineLength))*100)/100;`
Ok great. So now I have calculated all 3 sides of my isosceles.

Using this, I can calculate the 3 angles of the triangle. Solve using SSS (side, side, side)...

I have looked up some formulas to do this:

http://www.teacherschoice.com.au/Mat...e_trig_SSS.htm

Now as you can see, the formulas are pretty clear. But when I try to plug them in, I'm getting some wacky numbers that don't make sense so obviously I'm doing something wrong.

My hunch is that somewhere along the way my conversions from radians to degrees and such isn't working the way they should with the cos and sin formulas.

Can someone help me to translate those formulas into as3 as something flash can understand as a formula? If I could get the proper answer in degrees it would be great. I will post more as it comes to me. cheers.
Last edited by clot; November 2nd, 2007 at 11:25 AM.

2. Code:
```radians = Math.acos((Math.pow(side1, 2)) + Math.pow(side2, 2) - Math.pow(side3, 2) / (2 * side1 * side2));
degrees = Math.round (Radians * 180/Math.PI);
trace(degrees);```
That's the best I can come up with. Give it a shot.

I just tried it actually, it didn't work.
Last edited by mattrock23; November 2nd, 2007 at 11:49 PM.

3. 14
posts
Registered User
This should do the job (for any triangle, I believe). You just need to plug your side values into a, b and c. The results will suffer a little from floating point number messiness(values for an equilateral triangle will yield angles like 59.99999999999999, rather than 60) so rounding, as mattrock23 suggests or using Number.toPrecision() for display purposes will make the results look more like what you would expect for triangles that have angles that happen to be integers. Hope this helps.

//sides
var a:Number;
var b:Number;
var c:Number;
//angles
var A:Number;
var B:Number;
var C:Number;
//formula
A = Math.acos(((b*b) +(c*c) - (a*a))/ (2* b*c));
B = Math.acos(((a*a) +(c*c) - (b*b))/ (2* a*c));
C = Math.acos(((a*a) +(b*b) - (c*c))/ (2* a*b));
//results
trace('A: ' + (A * 180/Math.PI).toPrecision(6));
trace('B: ' + (B * 180/Math.PI).toPrecision(6));
trace('C: ' + (C * 180/Math.PI).toPrecision(6));

4. Last edited by Felixz; November 10th, 2007 at 10:55 AM.

5. 56
posts
Registered User
Awesome. OmniMouse's solution seems to work perfectly. (edit: not so sure now, see below)

This is greatness!

Now here's my tricky part...

Given that I know the x,y of 2 points that make up the triangle, how can I calculate the last x,y of the 3rd point? I will attach an image to explain what I mean in a few minutes.
Last edited by clot; November 4th, 2007 at 06:24 PM.

6. 56
posts
Registered User
Here's the idea : I'm confused as to how to find the final point. I realized early on that I will need the angles (which I have now) and the lengths of each side (which I also have). I'm just having trouble coming to grips with this last step. The values shown are meant to be examples to illustrate what I mean and shouldn't be taken at face value.

Also, I mentioned wanting my answer in degrees without knowing how behind the times I was with math. Omnimouse's solution works fine in radians as well (omitting the 180/Math.pi part obviously) so solving this using radians is good by me.

[img=http://img208.imageshack.us/img208/571/examplezb0.th.jpg]

Let me know if you can't see it and I will attach it to the forum. cheers.
Last edited by clot; November 3rd, 2007 at 03:52 PM.

7. 56
posts
Registered User
Ok, I'm back with some promising new info.

I found out that I can use triangulation to find a missing point using this formula:

Given a known point, P1 has values (x,y) - and that I know the length of the side (d) between P1 and my unknown point, P2 - and that I also know all of my angles - specifically, vertex angle at P2 (a2) - there is a formula to find the missing point...

(x+cosa2*d) - finds for missing x coordinate of P2
(y+sina2*d) - finds for missing y coordinate of P2

It still gives me some values that aren't correct but it's because I think I am either writing the formula wrong in flash, or not considering degrees vs radians, or both.

Can anyone help me on this last step? cheers, thanks for all the help so far.

As an update, I'm having doubts about the formulas calculating the angles. Yes, all 3 angles added together equal 180, but, and this is a BIG but, because it's an isosceles triangle, and the hypotenuse becomes fairly long, my vertex angles for the 2 equal sides should be quite small and the last angle should be quite large. Right now, the large angle stays at about 90 degrees and the 2 smaller angles are about 45 degrees each. Which is wrong. Why could this be?

Why would one use acos compared to cos? How does this affect the calculations?
Last edited by clot; November 4th, 2007 at 06:24 PM.

8. 14
posts
Registered User
Originally Posted by clot
As an update, I'm having doubts about the formulas calculating the angles. Yes, all 3 angles added together equal 180, but, and this is a BIG but, because it's an isosceles triangle, and the hypotenuse becomes fairly long, my vertex angles for the 2 equal sides should be quite small and the last angle should be quite large. Right now, the large angle stays at about 90 degrees and the 2 smaller angles are about 45 degrees each. Which is wrong. Why could this be?

Why would one use acos compared to cos? How does this affect the calculations?
acos is the arcosine. Felixz seems to be saying that arcosine is not the equivalent of inverse cosine. Maybe he is right in some technical sense--I am not a mathematician. It works, however. Cosine would not.

Could you give an example of some specific side lengths that are giving you these funny results? I can put some pretty extreme values in with no problems. Only time it gets weird is if the hypotenuse is impossibly large (i.e longer than 2x the two other sides).
Last edited by Omnimouse; November 5th, 2007 at 04:11 AM.

9. 56
posts
Registered User
Well, my values shouldn't be too large. My 2 equal sides won't get much larger than 200 each. Here's how I'm calculating the hypotenuse:

sideCh = int(Math.sqrt(2*(sideA*sideA))*100)/100;

It seems to give me the proper result for the longest side (hypotenuse)

here's my flow from there:

Code:
```angleA = Math.acos(((sideB*sideB) +(sideCh*sideCh) - (sideA*sideA))/ (2* sideB*sideCh));
angleB = Math.acos(((sideA*sideA) +(sideCh*sideCh) - (sideB*sideB))/ (2* sideA*sideCh));

angleCh = Math.acos(((sideA*sideA) +(sideB*sideB) - (sideCh*sideCh))/ (2* sideA*sideB));```
When tracing the angles - it's giving me 45 for each of the small angles and 90 for the large one. (conversely, the same ratios in radians as well)

I'm not sure why, it seems like it should all work. (The picture I attached earlier is a pretty close representation of sizes I'd be working with and also a good example of how the angles would look - which makes me wonder why I'd be getting even close to 90/45/45 with these calculations.)
Last edited by clot; November 5th, 2007 at 10:20 AM.

10. 14
posts
Registered User
It looks to me like your formula is the one for finding the length of a 'right isosceles' triangle, not just any old isosceles triangle. You would need to have a variable that represents the angle opposite the hypotenuse(or the height of the triangle) . The method that you are using (Pythagorean theorem) assumes a 90 degree angle implicitly, so it is not surprising that the angle calculator is giving you those numbers--they are the right ones for a right triangle.

Think about it. One could have a very tall and narrow isosceles triangle (100 x 100 x 1), or a very flat, wide one (100 x 100 x 199). Your formula will always return 141.42 for a length of 100, which is the correct number only if the angle common to the two sides is 90 degrees.

11. 56
posts
Registered User
hmm, this is troubling. Is there any way to solve my triangle by just knowing that 2 sides are the same? Essentially I want to solve for the hypotenuse and with sss (side,side,side) established, solve for my angles.

This is starting to look like a chicken or the egg problem.

12. I am 100% certain I can solve it; I've been programming trig into Flash for the past year, I just haven't the time right now. Wait a day or three.

13. 14
posts
Registered User
Originally Posted by clot
hmm, this is troubling. Is there any way to solve my triangle by just knowing that 2 sides are the same?
No. It is impossible to get "the" length of the third side of a triangle, if the only information you have is the length of two of the sides. You can find many possible solutions, but there is no one "correct" answer because an infinite number of answers that would all be correct. Basically any number that is bigger than zero and is smaller than 2x the length of the equal sides would be an acceptable result. To nail it down to one particular triangle, you just need more information.

Lets say both your sides are equal to 1, just to keep things simple. the third side could be 1.9999999999, or 1.5 or or 1 or 0.8 or 0.000001. All of those are equally correct.

Can you explain what the overall goal is--why you only know 2 sides and why you need to the angle measurements? Maybe there is a creative solution that works around your problem.

14. If the only givens you have are two points of the triangle, and the length of one side, then Omnimouse is right, you can't solve it.

Do you have the length of the other side? Or a single angle?

15. 56
posts
Registered User
Yes, I do only know 1 side, but, I also know that side is the same length as the other side. (The sides that are the same are shorter than the hypotenuse) The only other way that I can see around this issue : I think I can find the slope of what my second line should be. Will this help? If you check out my diagram the line drawn between point 2 and point 3 - if I know the slope for that line - that should help us? I'm not totally clear on using slope but if it can give us the hypotenuse (or I guess where the hypotenuse intersects) - I'm imagining that might give us point 3? Very awesome thanks to both of you for your help.

And just to clarify in case it doesn't make sense - the slope value that I can get is from another line elsewhere that I know has the same slope as my isosceles triangle line.
Last edited by clot; November 6th, 2007 at 11:24 AM.

Page 1 of 3 123 Last

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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