// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package math// Atan2 returns the arc tangent of y/x, using// the signs of the two to determine the quadrant// of the return value.//// Special cases are (in order)://// Atan2(y, NaN) = NaN// Atan2(NaN, x) = NaN// Atan2(+0, x>=0) = +0// Atan2(-0, x>=0) = -0// Atan2(+0, x<=-0) = +Pi// Atan2(-0, x<=-0) = -Pi// Atan2(y>0, 0) = +Pi/2// Atan2(y<0, 0) = -Pi/2// Atan2(+Inf, +Inf) = +Pi/4// Atan2(-Inf, +Inf) = -Pi/4// Atan2(+Inf, -Inf) = 3Pi/4// Atan2(-Inf, -Inf) = -3Pi/4// Atan2(y, +Inf) = 0// Atan2(y>0, -Inf) = +Pi// Atan2(y<0, -Inf) = -Pi// Atan2(+Inf, x) = +Pi/2// Atan2(-Inf, x) = -Pi/2func (, float64) float64 {ifhaveArchAtan2 {returnarchAtan2(, ) }returnatan2(, )}func atan2(, float64) float64 {// special casesswitch {caseIsNaN() || IsNaN():returnNaN()case == 0:if >= 0 && !Signbit() {returnCopysign(0, ) }returnCopysign(Pi, )case == 0:returnCopysign(Pi/2, )caseIsInf(, 0):ifIsInf(, 1) {switch {caseIsInf(, 0):returnCopysign(Pi/4, )default:returnCopysign(0, ) } }switch {caseIsInf(, 0):returnCopysign(3*Pi/4, )default:returnCopysign(Pi, ) }caseIsInf(, 0):returnCopysign(Pi/2, ) }// Call atan and determine the quadrant. := Atan( / )if < 0 {if <= 0 {return + Pi }return - Pi }return}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.