Results 1 to 21 of 21

Thread: Triangle Equations

  1. #1

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Triangle Equations

    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.

    vb Code:
    1. #Region " Sines "
    2.  
    3.         Private Function FindSineAngle(ByVal Side1 As Double, ByVal Side2 As Double, ByVal Angle As Double) As Double
    4.             Return RadianToDegree(Math.Asin((Side1 / Side2) * (Math.Sin(DegreeToRadian(Angle)))))
    5.         End Function
    6.  
    7.         Private Function FindSineSide(ByVal Side As Double, ByVal Angle1 As Double, ByVal Angle2 As Double) As Double
    8.             Return Side * ((Math.Sin(DegreeToRadian(Angle1)) / Math.Sin(DegreeToRadian(Angle2))))
    9.         End Function
    10. #End Region
    11.  
    12. #Region " Cosines "
    13.         Friend Function FindCosineSide(ByVal Side1 As Double, ByVal Side2 As Double, ByVal Angle As Double) As Double
    14.             'Get our variables setup and preprocessed for ease
    15.             Dim Side1A As Double = Side1 ^ 2.0R
    16.             Dim Side2A As Double = Side2 ^ 2.0R
    17.  
    18.             'Setup Formula
    19.             Return Math.Sqrt((Side1A + Side2A) - (2.0R * Side1 * Side2 * System.Math.Cos(DegreeToRadian(Angle))))
    20.         End Function
    21.  
    22.         Private Function FindCosineAngle(ByVal A As Double, ByVal B As Double, ByVal C As Double, ByVal Angle As CosineAngles) As Double
    23.             Dim SideA As Double = A ^ 2.0R
    24.             Dim SideB As Double = B ^ 2.0R
    25.             Dim SideC As Double = C ^ 2.0R
    26.             Dim Output As Double = Double.NaN
    27.  
    28.             Select Case Angle
    29.                 Case CosineAngles.AngleA
    30.                     Output = RadianToDegree(Math.Acos((SideA - SideB - SideC) / (-2.0R * B * C)))
    31.                 Case CosineAngles.AngleB
    32.                     Output = RadianToDegree(Math.Acos((SideB - SideA - SideC) / (-2.0R * A * C)))
    33.                 Case CosineAngles.AngleC
    34.                     Output = RadianToDegree(Math.Acos((SideC - SideB - SideA) / (-2.0R * A * B)))
    35.             End Select
    36.  
    37.             Return Output
    38.         End Function
    39. #End Region

    Enjoy.

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Triangle Equations

    These were made in vb.net 2008 btw
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    Quote Originally Posted by JuggaloBrotha View Post
    These were made in vb.net 2008 btw
    Would probably work in 2005, since project was compiled via 2.0 framework.

  4. #4
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Triangle Equations

    Quote Originally Posted by formlesstree4 View Post
    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?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #5

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    Quote Originally Posted by JuggaloBrotha View Post
    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.

  6. #6
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Triangle Equations

    Quote Originally Posted by formlesstree4 View Post
    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 ....)

    Quote Originally Posted by JuggaloBrotha View Post
    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!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  7. #7

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    ABC - points
    abc - sides/lines

    angles are in degrees.

  8. #8
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Triangle Equations

    Code:
          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.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  9. #9

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    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.

  10. #10
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Triangle Equations

    Quote Originally Posted by formlesstree4 View Post
    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.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  11. #11

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    FindSineAngle(SideA, SideB, AngleA)
    Example call.

  12. #12
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Triangle Equations

    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.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  13. #13

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    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
    Attached Files Attached Files

  14. #14
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Triangle Equations

    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.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  15. #15

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    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.

  16. #16
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Triangle Equations

    Quote Originally Posted by opus View Post
    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:
    Code:
    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.
    Quote Originally Posted by opus View Post
    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'
    Quote Originally Posted by opus View Post
    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.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  17. #17

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    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.

  18. #18
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Triangle Equations

    Quote Originally Posted by formlesstree4 View Post
    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.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  19. #19

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    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.

  20. #20
    New Member
    Join Date
    May 2009
    Posts
    2

    Re: Triangle Equations

    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:

    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.

  21. #21

    Thread Starter
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Posts
    3,250

    Re: Triangle Equations

    These functions aren't for finding points. Do some research on equations about finding points.

Posting Permissions

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



Click Here to Expand Forum to Full Width