Cacoon
Cacoon

Reputation: 2538

Finding a right angle in a triangle

I am working with the knowledge of all 3 sides of the triangle, they are inputted by the user. And I need to know if any of the angles will equal 90 degrees I have looked up the math for this but sadly have no idea how to attempt to use it

I am wokring out what kind of triangle the user has with the lengths of each side

 If First <> Second AndAlso Second <> Third AndAlso First <> Third Then
     MsgBox("Triangle is scalene")
 ElseIf First = Second AndAlso Second = Third AndAlso First = Third Then
     MsgBox("Triangle is equilateral")
 ElseIf First = Second Or Second = Third Or First = Third Then
     MsgBox("Triangle is isosceles")
 ElseIf rightangle Then
     MsgBox("Triangle is right angle")
 Else
     MsgBox("UFT - Unidentified flying triangle")
 End If

I am not sure where to start, not form lack of trying

Upvotes: 0

Views: 664

Answers (3)

Sarvesh Mishra
Sarvesh Mishra

Reputation: 2072

This is what you need to check using sides. You may need to round off values to avoid problem of floating point comparisons.

If First = Math.Sqrt(Second * Second + Third * Third) OrElse Second = Math.Sqrt(First * First + Third * Third) OrElse Third = Math.Sqrt(First * First + Second * Second) Then
    MsgBox("Triangle is right angle")
End If

Upvotes: 2

Hayley Guillou
Hayley Guillou

Reputation: 3973

Basic outline of what you need to do:

  1. Get the three side lengths from the user

  2. Find the three angles

    • Use Law of Cosine to find the first angle
    • Use Law of Sine to find the second angle
    • Find the third angle by using 180 - (first + second)
  3. Check how many of these angles are 90 degrees and apply any logic you need.

Upvotes: 0

xpda
xpda

Reputation: 15813

In a right triangle, the sum of the squares of the two shorter sides is equal to the square of the long side. For example, 3^2 + 4^2 = 5^2, so a triangle with sides of length 3, 4, and 5 is a right triangle.

Upvotes: 3

Related Questions