im trying to write a application that reads 3 nonzero values when i enter then and the applications determines wheather they could represent the sides of a tirangle
The Pythagorean theorem can be generalized to the law of cosines:
which is valid for all triangles, even if γ is not a right angle.
So apply some simple trigonometry - you can calculate the angle between them using a tan function and then you can apply something like the following to calculate the other side - and see if this matches the 3rd side dimension provided to you.
Function IsTriangle(ByVal Side1 As Integer, ByVal Side2 As Integer, ByVal Side3 As Integer) As Boolean
'The sum of the measures of any two sides of any triangle
'is greater than the measure of the third side.
If ((Side1 + Side2) <= Side3) Then
Return False
ElseIf ((Side2 + Side3) <= Side1) Then
Return False
ElseIf ((Side3 + Side1) <= Side2) Then
Return False
Else
Return True
End If
End Function
When doing a SSS (Side, Side, Side) comparision the following statement is mathmatically correct:
'The sum of the measures of any two sides of any triangle is greater than the measure of the third side.
Therfore when just given the length of three sides of a triangle you can check whether or not they can be made into a valid trianlge with the code given...if doing any calcualtions based upon angle AAA, ASA, SAS etc...then yes basic trig would be neccessary.... the pythagorean therom and law of cosines come into play
please help
Roger_Melb
My thought and distant recollections of mathematics(trigonometry) would be that you will need to basically calculate the triangle
So you would be using the sin, cos and tan functions contained in the system.math namespace
That said on http://en.wikipedia.org/wiki/Triangle
So apply some simple trigonometry - you can calculate the angle between them using a tan function and then you can apply something like the following to calculate the other side - and see if this matches the 3rd side dimension provided to you.
chirag.dave
Public
Function IsTriangle(ByVal Side1 As Integer, ByVal Side2 As Integer, ByVal Side3 As Integer) As Boolean 'The sum of the measures of any two sides of any triangle 'is greater than the measure of the third side. If ((Side1 + Side2) <= Side3) Then Return False ElseIf ((Side2 + Side3) <= Side1) Then Return False ElseIf ((Side3 + Side1) <= Side2) Then Return False Else Return True End If End FunctionStarsFire
Now I think about it - for a 3 side comparison then this looks correct and oh so simple.
As soon as you start to include any angle then trig is necessary and the provided namespaces are where these functions are.
DJ Pandamonium
When doing a SSS (Side, Side, Side) comparision the following statement is mathmatically correct:
'The sum of the measures of any two sides of any triangle is greater than the measure of the third side.
Therfore when just given the length of three sides of a triangle you can check whether or not they can be made into a valid trianlge with the code given...if doing any calcualtions based upon angle AAA, ASA, SAS etc...then yes basic trig would be neccessary.... the pythagorean therom and law of cosines come into play