Results 1 to 5 of 5

Thread: [RESOLVED] arccos problems?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2009
    Posts
    43

    Resolved [RESOLVED] arccos problems?

    Hello..

    I'm already knew there is no ArcCos or ArcSin in Visul Basic..

    after searching on internet i've got this code..

    Code:
    Public Function Arccos(X) As Double
       If Round(X, 8) = 1# Then Arccos = 0#: Exit Function
       If Round(X, 8) = -1# Then Arccos = PI: Exit Function
       Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
    End Function
    unfortunately, i dont know why the answer was wrong..

    i try on calculator cos-1 (-0.7071) = 134.999

    but when i use the code above, the result give me = 1.583137

    PS: already use some kind like convert radiant to degree or reversal .. (*PI/180)

    any help?

  2. #2
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: arccos problems?

    Code:
    Math.Acos(.5)
    will return the arc cosine of .5

    Asin and Atan also work for arc sines and arc tangents

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2009
    Posts
    43

    Re: arccos problems?

    sorry.. but it seems.. math.Acos / math.Asin was not arc cosinus (cos-1) or arc sinus (sin-1) on visual basic...

    the result math.Acos(-0.7071) = 2.35619
    Last edited by j0e2; Jan 4th, 2010 at 02:41 AM.

  4. #4
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: arccos problems?

    yeah, 2.35619 is the answer in Radian form, you want it in degrees just convert it like this

    Code:
    Math.Acos(.5)*180.0 / Math.PI

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2009
    Posts
    43

    Re: arccos problems?

    wow..greatz..
    i think converting to radiant-degree just like this
    Code:
    math.Acos(.5*180/PI)


    THX philly..

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