Website Design United States, Website Design California, Website Designing United States, Website Designing California

ArcSin - Visual Basic 6

lets assume you have a triangle with an angle of 90 degrees, you know the length of the long side (A=5) and one of lengths of the short sides (B=3)


?
/|
/ |
/ |
A / | C
/ 5 |
/ |
/___3__|
B
(of course we then know that the other short side has length (C=4) (because 3*3 + 4*4 = 5*5) .. but we wont use that in this example)

suppose you want to calculate the angle of the angle across the short side (between A and C)
and want to have the answer in degrees instead of in radians

to calculate the angle you have to use the arcsin()

sin(angle)=b/a thus angle=arcsin(b/a)

the vb help tells us that

Arcsin(X) = Atn(X / Sqr(-X * X + 1))


thus your code becomes:

Private Sub Command1_Click()
Dim sngA As Single, sngB As Single
Dim sngRatio As Single
Dim sngAngle As Single
Dim sngPI As Single
sngPI = 4 * Atn(1)
sngA = 5
sngB = 3
sngRatio = sngB / sngA
sngAngle = ArcSin(sngRatio)
sngAngle = sngAngle * 180 / sngPI
Caption = CStr(sngAngle)
End Sub

Public Function ArcSin(sngX As Single) As Single
ArcSin = Atn(sngX / Sqr(-sngX * sngX + 1))
End Function

' as you can see i calculate the value of PI using

' sngPI = 4 * Atn(1)

' this is true because

' tan(1) = PI / 4 'in radians
' tan(1) = 45 'in degrees

' all this comes from the vb help files ... its just combined
' in a very simple project to show how it works
' the substitution for the arccos() is

' Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

' you can find the other substitutions for the goniometric
' functions in the help files under 'Derived Math Functions'

WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com