Results 1 to 7 of 7

Thread: Sin to the Negative one (VB6) [Resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    3

    Sin to the Negative one (VB6) [Resolved]

    Hi, I know this is a simple noob question but I can't seem to find the answer. Anyone know what the Method is for calculating sin^-1(Opp/Hyp) in Visual Basic 6? I knew how at one point but I jsut can't seem to remember. Thanks n Advance.

    Edit: I know how to find the angle in the real world, but how do I do it in vb?
    Last edited by sonic1015; Feb 8th, 2007 at 08:43 AM.

  2. #2
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Sin to the Negative one (VB6)

    Alright, I didn't write this but it is said to work:
    VB Code:
    1. Public Function ArcSin(arg As Single) As Single
    2.  
    3. If arg > 1 Or arg < -1 Then 'outside domain!
    4. ArcSin = 0
    5. Exit Function
    6. End If
    7.  
    8. If arg = 1 Then 'div by 0 checks
    9.    ArcSin = pi / 2#
    10.    Exit Function
    11. End If
    12.  
    13. If arg = -1 Then
    14.    ArcSin = pi / -2#
    15. Else
    16.    ArcSin = Atn(arg / Sqr(1 - (arg ^ 2)))
    17. End If
    18.  
    19. End Function


    "X-mas is 24.Desember you English morons.." - NoteMe

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    3

    hmmm...

    I thought there was some built in function for this. That would have made life a bit easier.

    Oh well. Thankyou though it does work.

    Do you happen to know the Cosine and Tan ones too? I thought they would all be similar as built in functions but...yeah I guess they probably wouldn't would they...
    Last edited by sonic1015; Feb 8th, 2007 at 12:01 AM.

  4. #4
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734

    Re: Sin to the Negative one (VB6)

    Here are all three of them, once again I didn't write them:

    VB Code:
    1. Public Function ArcCos(A As Double) As Double
    2.  
    3.   'Inverse Cosine
    4.  
    5.     On Error Resume Next
    6.  
    7.         If A = 1 Then
    8.             ArcCos = 0
    9.             Exit Function
    10.         End If
    11.  
    12.         ArcCos = Atn(-A / Sqr(-A * A + 1)) + 2 * Atn(1)
    13.     On Error GoTo 0
    14.  
    15. End Function
    16.  
    17. Public Function ArcSin(x As Double) As Double
    18.  
    19.   'Inverse Sine
    20.  
    21.     On Error Resume Next
    22.         ArcSin = Atn(x / Sqr(-x * x + 1))
    23.     On Error GoTo 0
    24.  
    25. End Function
    26.  
    27. Public Function ArcTan(x As Double) As Double
    28.  
    29.   'Inverse Tangent
    30.  
    31.     On Error Resume Next
    32.         ArcTan = Atn(x) * (180 / PI)
    33.     On Error GoTo 0
    34.  
    35. End Function


    "X-mas is 24.Desember you English morons.." - NoteMe

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    3

    Re: Sin to the Negative one (VB6)

    Ok, Thankyou very much. They all work and I've got my program working so far. Thanks

  6. #6
    Addicted Member
    Join Date
    Mar 2002
    Posts
    229

    Re: Sin to the Negative one (VB6) [Resolved]

    hey bud,

    you prolly won't read this now that you have an answer but if you press F2 in the VB ide, then you'll get a list of all built in functions organized by classes. If you scroll the list on the left to Math, then you'll see arcsin, arccos, atan, and a whole bunch of other ones.

    good luck

  7. #7
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Sin to the Negative one (VB6) [Resolved]

    If you see those, then you aren't using VB6...

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