Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scientific

Status
Not open for further replies.

AdamWhitehouse

Programmer
Aug 7, 2000
34
0
0
GB
Ok, why does this happen & what do I do to get the right result?

I am trying to find Sin(70.4170)in degree's
The answer is 0.9421569 degrees.

My Vb6 gives me 0.96409144 Radians which when I multiply by the radians to degrees formula 180/pi (57.2957)gives me a silly figure of 55.23 degree's which I know is not right.

Please help!!!!!!!!!!!!!!
 
AdamWhitehouse

I am not sure where you are going wrong, but the code below produces the following results.


sin of 70.417 is 0.942156941803432
inversesin of 0.942156941803432 is 70.417


Code:
Dim dAngle As Double, dArcAngle As Double
Dim dSin As Double, dArcSin As Double
Dim dRad As Double

dAngle = 70.417
dRad = dAngle * pii / 180
dSin = Sin(dRad)
Debug.Print "sin of " & CStr(dAngle) & " is " & CStr(dSin)
dArcSin = Atn(dSin / Sqr(-dSin * dSin + 1))
dArcAngle = dArcSin * 180 / pii
Debug.Print "inversesin of " & CStr(dSin) & " is " & CStr(dArcAngle)

I hope that this provides some illumination.

BTW, I had to define pii as a const, does anyone know whether PI is defined in VB (its not something I use much!)

Take care


Matt
 
Hi,

PI is not a VB constant !

also, if your one for absoluteness PI then i use a function

Public Function PI() As Double
PI = 4 * Atn(1)
End Function
 
You need to convert degrees to radians first then take the sin.

mySin = sin(myDegrees/180*pi)
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
thanks johnwm, I had forgotten that on my previous calc I had converted to degrees, and therefore needed to convert back to Rad's before moving to my next calc.

Problem sorted.. thanks to all who responded.
Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top