Here, We will learn how to get the arc tangent of y/x in go. We can get it by using Atan2() function in math package in go golang.
Function prototype:
func Atan2(y, x float64) float64
Return value:
Atan2() function in math package returns
the arc tangent of y/x by using the signs of
the two to determine the quadrant of the
return value.
Example with code:
package main
import (
"fmt"
"math"
)
func main() {
no := math.Atan2(1, 2)
fmt.Printf("%.2f\n", no)
no = math.Atan2(0, 0)
fmt.Printf("%.2f\n", no)
no = math.Atan2(1, 4)
fmt.Printf("%.2f\n", no)
no = math.Atan2(3, 4)
fmt.Printf("%.2f\n", no)
no = math.Atan2(5, 2)
fmt.Printf("%.2f\n", no)
}
Output:
0.46
0.00
0.24
0.64
1.19
To learn more about golang, Please refer given below link:
https://techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/