ATan2() Ceil()

Jim Brown

Active Member
Licensed User
Longtime User
Can you implement the ATan2() function Erel?
All parameters and return values as Double
B4X:
r=ATan2(y,x)    - return value in radians
d=ATan2D(y,x)  - return value in degrees

b4a has Floor() but no Ceil()
Is Round() the exact equivalent to Ceil()?
 

klaus

Expert
Licensed User
Longtime User
The Ceil code should be:
B4X:
Sub Ceil(Number As double) As double
    Dim f As Double
    f = Floor(Number)
    If f [COLOR=red]<[/COLOR] Number Then Return f Else Return f + 1
End Sub

Best regards.

EDIT: The code above is wrong Erel's code is right!
 
Last edited:

Jim Brown

Active Member
Licensed User
Longtime User
Thanks Erel
for ATan2D() I am using this at the moment (as used in my SnookerSim posted in user creations):
B4X:
Sub ATan2D(y As Float,x As Float) As Float
   If x<0 Then
      If y<0 Then Return ATanD(y/x)-180.0
      Return ATanD(y/x)+180.0
   End If
   Return ATanD(y/x)
End Sub
 
Top