Click to See Complete Forum and Search --> : Triangle Equations
formlesstree4
May 16th, 2009, 08:14 PM
These are some equations you can use to calculate Sides and Angles of triangles. Correctly used, one may solve the entire triangle with just a few sides and angles.
#Region " Sines "
Private Function FindSineAngle(ByVal Side1 As Double, ByVal Side2 As Double, ByVal Angle As Double) As Double
Return RadianToDegree(Math.Asin((Side1 / Side2) * (Math.Sin(DegreeToRadian(Angle)))))
End Function
Private Function FindSineSide(ByVal Side As Double, ByVal Angle1 As Double, ByVal Angle2 As Double) As Double
Return Side * ((Math.Sin(DegreeToRadian(Angle1)) / Math.Sin(DegreeToRadian(Angle2))))
End Function
#End Region
#Region " Cosines "
Friend Function FindCosineSide(ByVal Side1 As Double, ByVal Side2 As Double, ByVal Angle As Double) As Double
'Get our variables setup and preprocessed for ease
Dim Side1A As Double = Side1 ^ 2.0R
Dim Side2A As Double = Side2 ^ 2.0R
'Setup Formula
Return Math.Sqrt((Side1A + Side2A) - (2.0R * Side1 * Side2 * System.Math.Cos(DegreeToRadian(Angle))))
End Function
Private Function FindCosineAngle(ByVal A As Double, ByVal B As Double, ByVal C As Double, ByVal Angle As CosineAngles) As Double
Dim SideA As Double = A ^ 2.0R
Dim SideB As Double = B ^ 2.0R
Dim SideC As Double = C ^ 2.0R
Dim Output As Double = Double.NaN
Select Case Angle
Case CosineAngles.AngleA
Output = RadianToDegree(Math.Acos((SideA - SideB - SideC) / (-2.0R * B * C)))
Case CosineAngles.AngleB
Output = RadianToDegree(Math.Acos((SideB - SideA - SideC) / (-2.0R * A * C)))
Case CosineAngles.AngleC
Output = RadianToDegree(Math.Acos((SideC - SideB - SideA) / (-2.0R * A * B)))
End Select
Return Output
End Function
#End Region
Enjoy.
JuggaloBrotha
May 16th, 2009, 08:17 PM
These were made in vb.net 2008 btw
formlesstree4
May 16th, 2009, 08:18 PM
These were made in vb.net 2008 btw
Would probably work in 2005, since project was compiled via 2.0 framework.
JuggaloBrotha
May 18th, 2009, 02:03 PM
Would probably work in 2005, since project was compiled via 2.0 framework.These functions yes, the others would not because because of the IF statements, are we still using those?
formlesstree4
May 18th, 2009, 03:42 PM
These functions yes, the others would not because because of the IF statements, are we still using those?
The program is compiled using the 2.0 framework, so there's no compatibility issues.
opus
May 19th, 2009, 01:04 AM
These are some equations you can use to calculate Sides and Angles of triangles.
Could you use some more decriptions on what value is meant to be what part of a triangle and if an angle is in radians or degree. I'd use the standard triangle-nomination (A, B, C for points, a, b, c for lines ....)
These functions yes, the others would not because because of the IF statements, are we still using those?
What IF statements, the OP didn't use any and why shouldn'T we use them anymore? I can'T think of doing code WITHOUT an IF!
formlesstree4
May 19th, 2009, 01:06 AM
ABC - points
abc - sides/lines
angles are in degrees.
opus
May 19th, 2009, 01:09 AM
Private Function FindSineAngle(ByVal Side1 As Double, ByVal Side2 As Double, ByVal Angle As Double) As Double
Return RadianToDegree(Math.Asin((Side1 / Side2) * (Math.Sin(DegreeToRadian(Angle)))))
End Function
I don't see any a,b,c only Side1 and Side2, which angle is Angle then, the one between Side1 and Side2 or what.
formlesstree4
May 19th, 2009, 01:10 AM
It's a generic equation, it takes two sides. you decide if you give it b and c, a and c, or b and c, and it will return appropriate angle.
opus
May 19th, 2009, 01:14 AM
It's a generic equation, it takes two sides. you decide if you give it b and c, a and c, or b and c, and it will return appropriate angle.
But which angle is the "appropriate" one? The angle that is formed between Side1 and Side2 or one of the two others, you were talking of a triangle, like three angles.
formlesstree4
May 19th, 2009, 01:20 AM
FindSineAngle(SideA, SideB, AngleA)
Example call.
opus
May 19th, 2009, 01:49 AM
Let's make an example:
Triangle has sides Side1=1, Side2=1, the angle between Side1 and Side2 is 45 degrees.
Using your formula FindSineAngle, I get:
ASin( Side1/Side2)= Asin (1/1) = 1.570796 (that is in Radians)
Sin(DegreeToRadian(Angle))=Sin(PI/180*(45))=0.707106
RadianToDegree(Asin((Side1 / Side2) * (Sin(DegreeToRadian(Angle)))))=
180/PI*(1.570796*0.707106)=63.63961031
However, I do expect the Sinus of 45 to be 0.707106.
formlesstree4
May 19th, 2009, 02:06 AM
Look at this program. It uses all the equations successfully.
Me and Juggalo created this application, and it has been tested by a district certified math teacher. these equations do work :)
opus
May 19th, 2009, 03:44 AM
Attached project not running for me :-((
But if a "district certified teacher" looked it over, it HAS to be correct.
However I don't get any clue.
formlesstree4
May 19th, 2009, 07:57 AM
Attached project not running for me :-((
But if a "district certified teacher" looked it over, it HAS to be correct.
However I don't get any clue.
Can you at least look at the source? If you can examine the source, you can see how each angle and side is determined. The equations are just modified forms of the Laws of Sine and Laws of Cosine. I modified them to work in the program.
JuggaloBrotha
May 19th, 2009, 03:26 PM
What IF statements, the OP didn't use any and why shouldn'T we use them anymore? I can'T think of doing code WITHOUT an IF!Here's an example of the IF statement I'm talking about:MyVar = IF(SomeBooleanEvalution, TruePart, FalsePart)That type of IF statement only works in VS2008. We were using it at one point and I was just verifying that before adam (formlesstree4) states that it'll work in VS2005 and 2008.I don't see any a,b,c only Side1 and Side2, which angle is Angle then, the one between Side1 and Side2 or what.That part could be changed to make it more obvious, but in short:
Angle1 is equivalent to A
Angle2 is equivalent to B
Angle3 is equivalent to C
Side1 is equivalent to a
Side2 is equivalent to b
Side3 is equivalent to c
In code, for me, it's easier to identify it as 'Side1' instead of 'a'Attached project not running for me :-((
But if a "district certified teacher" looked it over, it HAS to be correct.
However I don't get any clue.His teacher says it works, I haven't asked a math person to test it on my end yet, but if you do use the functions here it's still common sense to either test them yourself or have someone else test them for you.
formlesstree4
May 19th, 2009, 04:05 PM
That type of IF statement only works in VS2008. We were using it at one point and I was just verifying that before adam (formlesstree4) states that it'll work in VS2005 and 2008.
I assume it would, because the code does compile to the 2.0 framework..but then again, that never means something automatically works.
JuggaloBrotha
May 19th, 2009, 06:10 PM
I assume it would, because the code does compile to the 2.0 framework..but then again, that never means something automatically works.Just because it works on the 2.0 Framework doesn't mean VS 2005 can understand the syntax.
VS 2008 knows how to compile the IF() statement to the 2.0 Framework MSIL code but VS 2005 doesn't.
formlesstree4
May 19th, 2009, 06:15 PM
Just because it works on the 2.0 Framework doesn't mean VS 2005 can understand the syntax.
VS 2008 knows how to compile the IF() statement to the 2.0 Framework MSIL code but VS 2005 doesn't.
Unless someone has vb.net 2005, then I can't truly say that it works. The IF statements may not be 2005 compatible, but the equations are.
zipperipper
May 20th, 2009, 01:30 PM
hi i want to know how to get the third point of a triangle..
i have point A and point B and the Length of all sides.
now i need to get Point C by using an offset from A.. but only by using the lengths of ab, bc and ac.
here is an example:
http://i686.photobucket.com/albums/vv227/zipperipper/trianglecget.jpg
it needs to be a function which is given the lengths of the lines and returns the offset.
also it doesnt matter if the x of offset is more/less than ab.
thanks.
formlesstree4
May 20th, 2009, 04:56 PM
These functions aren't for finding points. Do some research on equations about finding points.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.