atan2
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
fun atan2(y: Double, x: Double): Double
fun atan2(y: Float, x: Float): Float
Returns the angle theta
of the polar coordinates (r, theta)
that correspond to the rectangular coordinates (x, y)
by computing the arc tangent of the value y / x; the returned value is an angle in the range from -PI
to PI
radians.
Special cases:
-
atan2(0.0, 0.0)
is0.0
-
atan2(0.0, x)
is0.0
forx > 0
andPI
forx < 0
-
atan2(-0.0, x)
is-0.0
for 'x > 0and
-PIfor
x < 0` -
atan2(y, +Inf)
is0.0
for0 < y < +Inf
and-0.0
for '-Inf < y < 0` -
atan2(y, -Inf)
isPI
for0 < y < +Inf
and-PI
for-Inf < y < 0
-
atan2(y, 0.0)
isPI/2
fory > 0
and-PI/2
fory < 0
-
atan2(+Inf, x)
isPI/2
for finitex
y -
atan2(-Inf, x)
is-PI/2
for finitex
-
atan2(NaN, x)
andatan2(y, NaN)
isNaN
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/atan2.html