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?
Re: Sin to the Negative one (VB6)
Alright, I didn't write this but it is said to work:
VB Code:
Public Function ArcSin(arg As Single) As Single
If arg > 1 Or arg < -1 Then 'outside domain!
ArcSin = 0
Exit Function
End If
If arg = 1 Then 'div by 0 checks
ArcSin = pi / 2#
Exit Function
End If
If arg = -1 Then
ArcSin = pi / -2#
Else
ArcSin = Atn(arg / Sqr(1 - (arg ^ 2)))
End If
End Function
Re: Sin to the Negative one (VB6)
Here are all three of them, once again I didn't write them:
VB Code:
Public Function ArcCos(A As Double) As Double
'Inverse Cosine
On Error Resume Next
If A = 1 Then
ArcCos = 0
Exit Function
End If
ArcCos = Atn(-A / Sqr(-A * A + 1)) + 2 * Atn(1)
On Error GoTo 0
End Function
Public Function ArcSin(x As Double) As Double
'Inverse Sine
On Error Resume Next
ArcSin = Atn(x / Sqr(-x * x + 1))
On Error GoTo 0
End Function
Public Function ArcTan(x As Double) As Double
'Inverse Tangent
On Error Resume Next
ArcTan = Atn(x) * (180 / PI)
On Error GoTo 0
End Function
Re: Sin to the Negative one (VB6)
Ok, Thankyou very much. They all work and I've got my program working so far. Thanks
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
Re: Sin to the Negative one (VB6) [Resolved]
If you see those, then you aren't using VB6...