Android Question Deg2Rad

Prosg

Active Member
Licensed User
Longtime User
Hello,

i use this function php Deg2Rad but i need this in my b4a code ? is there a same function ?

B4X:
  Dim lonMin, lonMax, latMin, latMax As Double
  
    lonMin = longitude - currentDistance/Abs(Cos(Deg2Rad (latitude))*111)

regards
 

JordiCP

Expert
Licensed User
Longtime User
AFAIK, it does not exist as a core function

But you can do your own function
B4X:
Sub Deg2Rad(myDeg As Double) As Double
    Return cPI*myDeg/180
End Sub

--EDIT--

Or use cosD(..), which already takes the argument in degrees
 
Upvote 0

udg

Expert
Licensed User
Longtime User
As far as I know, one degree is equal 0.01745329252 radians
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
you can write your own function:
radians = degrees * (pi/180)
degrees = radians * (180/pi)

you have to think about, how precise you want have the value of pi (3.1415 or 3.14159265359...) or you can calculate it like Pi = 4 * ArcTan(1)
 
Upvote 0
Top