# How do i use trigonometry to calculate the type of triangle i am input

Page 1 of 1

## 5 Replies - 4133 Views - Last Post: 14 November 2009 - 09:02 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=137833&amp;s=eb16735ce899efd0ff911fd348adaf51&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Keevu

Reputation: 0
• Posts: 41
• Joined: 13-September 09

# How do i use trigonometry to calculate the type of triangle i am input

Posted 09 November 2009 - 01:08 PM

I need to calculate which type of triangle The user inputs, how do i use trigonometry to calculate which type of triangle it is equilateral, right, or right iscoseles? I have been trying to figure this out for about 2 weeks and I am completely stuck, will someone help me out?

thanks alot.

```using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace triangle_mthhttp://www.dreamincode.net/forums/index.php?act=Post&CODE=02&f=84&t=137833&qpid=827787
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

//check to see if user typed a number into text box.
public bool IsNumeric(string s)
{
try
{
Double.Parse(s);
}
catch
{
return (false);
}

return (true);
}

//calculate button
private void button1_Click(object sender, EventArgs e)
{
if (!IsNumeric(textBox1.Text) ||
!IsNumeric(textBox2.Text) ||
!IsNumeric(textBox3.Text))
{
MessageBox.Show("Enter side A, B, and C.");
return;//error, so leave
}

{
float sidea = float.Parse(textBox1.Text); //convert string to number
float sideb = float.Parse(textBox2.Text); //convert string to number
float sidec = float.Parse(textBox3.Text); //convert string to number

Classify tri1 = new Classify();//instance of Class

float peri = tri1.Peri(sidea, sideb, sidec);
float s = ((sidea + sideb + sidec) / 2);
float area = (s * (s - sidea) * (s - sideb) * (s - sidec));

textBox4.Text = peri.ToString(); //Perimeter
textBox5.Text = area.ToString(); //area
}
}

//**************************************************
// Count class:: Implement methods Add and Subtract.
// This class can also be used as a "base" class
// last updated 9/27/09 (efa)
//**************************************************
public class MyMath
{
public float Add(float n1, float n2)
{
return (n1 + n2);
}

public float Sub(float n1, float n2)
{
return (n1 - n2);
}
}

//**************************************************
// Group class:: Implement methods Multiply and Divide.
// last updated 9/27/09 (efa)
//**************************************************
public class TriMath:MyMath //This class has inherited from
{						//the base class "Count"
public float Peri(float sidea, float sideb, float sidec)
{
return (sidea + sideb + sidec);
}

public float Div(float n1, float n2)
{
return (n1 / n2);
}
}

//**************************************************
// Group MyMath:: Implement method Pow and inherite
// other methods from "Group" and "Count" classes.
// last updated 9/27/09 (efa)
//**************************************************
public class Classify:TriMath
{
public float Pow(float n1, float n2)
{
return ( (float) Math.Pow(n1,n2) ); //n1 raised to the n2 power
}
}

}
}
```

This post has been edited by Keevu: 09 November 2009 - 01:09 PM

Is This A Good Question/Topic? 0

## Replies To: How do i use trigonometry to calculate the type of triangle i am input

### #2 PsychoCoder

Reputation: 1663
• Posts: 19,853
• Joined: 26-July 07

## Re: How do i use trigonometry to calculate the type of triangle i am input

Posted 09 November 2009 - 01:08 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
• Post the code you're having problems with
• Post the exact error you're receiving, if you are receiving one
• If no error explain what the code is doing versus what you want it to do
• Post your question in the body of your post, not the description field

### #3 Keevu

Reputation: 0
• Posts: 41
• Joined: 13-September 09

## Re: How do i use trigonometry to calculate the type of triangle i am input

Posted 09 November 2009 - 01:12 PM

PsychoCoder, on 9 Nov, 2009 - 12:08 PM, said:

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
• Post the code you're having problems with
• Post the exact error you're receiving, if you are receiving one
• If no error explain what the code is doing versus what you want it to do
• Post your question in the body of your post, not the description field

I do not know how to get the code to calculate the type of triangle it is. It needs to label the triangle either a right triangle, an equilateral triangle, or a right isosceles triangle. I cannot figure out how to do this and I have been working for 2 weeks.

edit: and there are no errors btw.

This post has been edited by Keevu: 09 November 2009 - 01:16 PM

### #4 Momerath

• D.I.C Lover

Reputation: 1021
• Posts: 2,463
• Joined: 04-October 09

## Re: How do i use trigonometry to calculate the type of triangle i am input

Posted 09 November 2009 - 01:42 PM

equilateral = all sides must be equal length
right triangle = sum of square of short sides = square of long side
other - not one of the above.

### #5 Keevu

Reputation: 0
• Posts: 41
• Joined: 13-September 09

## Re: How do i use trigonometry to calculate the type of triangle i am input

Posted 13 November 2009 - 03:59 PM

Momerath, on 9 Nov, 2009 - 12:42 PM, said:

equilateral = all sides must be equal length
right triangle = sum of square of short sides = square of long side
other - not one of the above.

can you give me an equation fr right triangle.. I am still having trouble I have tried but its not working.

### #6 Qball522

Reputation: 6
• Posts: 86
• Joined: 06-October 08

## Re: How do i use trigonometry to calculate the type of triangle i am input

Posted 14 November 2009 - 09:02 AM

Correct me if I am wrong.

Right triangle has 2 sides squared that equal the other side squared. ie. A^2 + B^2 = C^2

There are 3 types of triangles when it come to length.
1) Equilateral= all 3 side of equal length.
2) Isosceles= 2 side of equal length.
3) Scalene = no 2 side are equal, all 3 side have different length.

If you are using lengths of all the sides, it shouldn't be that difficult.
If however you are using points on a coordinate plane that is a little tricky.
To get the distance between 2 points the formula is as follows

D(P, Q) = SquareRoot((x1 - x2) ^ 2 + (y1- y2) ^ 2)

Where:
D = Distance
P = First Point
Q = Second Point

Hope this has helped.