Results 1 to 10 of 10

Thread: Coding Tan, Sine, and Cosine

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    New South Wales, Australia
    Posts
    55

    Wink Coding Tan, Sine, and Cosine

    Mmmmmm bit of problem today.

    I am coding a calculator except i need Tangent, Sine, and Cosine. Problem is how do i code them?? Is there a number combo for them or....yteah well how??

    Any help would be Graciously accepted.

    From Darcey Pollard - President of Evil Penguin Enterprises
    Last edited by darcey_123; Jun 20th, 2005 at 08:50 PM.

  2. #2
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: Coding Tan, Sine, and Cosine

    Try using the "Tan", "Sin" and "Cos" commands. I've never had call to use them but know they're there

  3. #3
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Coding Tan, Sine, and Cosine

    Sin (X)
    Tan (X)
    Cos (X)

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    New South Wales, Australia
    Posts
    55

    Cool Re: Coding Tan, Sine, and Cosine

    How would i code that for a calculator??

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Coding Tan, Sine, and Cosine

    Those are the functions you will need.

    Example:

    VB Code:
    1. txtResult=TAN('your number')
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    New Member
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    12

    Re: Coding Tan, Sine, and Cosine

    any way to get inverse ratios?

  7. #7
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Coding Tan, Sine, and Cosine

    Quote Originally Posted by Netterhead1
    any way to get inverse ratios?
    VB supports Sin(), Cos(), Tan()

    The rest you can get simply as you do in maths:
    Cot = 1/Tan(x)
    Sec = 1/Cos(x)
    Cosec = 1/Sin(x)

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  8. #8
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Coding Tan, Sine, and Cosine

    As in math, all others can be derived from those three functions.

  9. #9
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Coding Tan, Sine, and Cosine

    Also, we all forgot Atn() which is arctangens.

    Look at this page: http://www.engineering.usu.edu/cee/f...s_Examples.htm

    it has great examples. It has the examples for working with trigonometry

  10. #10
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Coding Tan, Sine, and Cosine

    Usually when people talk about inverse functions in trigonometry they are referring to the functions ArcCos, ArcSin and ArcTan.

    Since the ArcTan function is built in, here is how to get the other two
    VB Code:
    1. Option Explicit
    2.  
    3. Const Pi = 3.14159265358979
    4. Const PiOn2 = 1.5707963267949
    5.  
    6. Function ACos(x As Double) As Double
    7.  ACos = PiOn2 - Atn(x / Sqr(1 - x ^ 2))
    8. End Function
    9.  
    10. Function ASin(x As Double) As Double
    11.     ASin = Atn(x / Sqr(1 - x ^ 2))
    12. End Function

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