Standard library / math/cmplx
cmplx.Rect()
Converts polar radius and angle in radians into complex Cartesian coordinates. Expected stdout: '2 0\n'.
Formal Syntax & Structure
go syntaxgo
func Rect(r, θ float64) complex128Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | float64 | Radius. |
| θ | float64 | Angle in radians. |
Return Value
complex128
Converts polar radius and angle in radians into complex Cartesian coordinates.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/cmplx")
func main() { z := cmplx.Rect(2, 0) fmt.Printf("%.6g %.6g\n", real(z)+0.0, imag(z)+0.0)}