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) complex128

Parameters & Attributes

NameTypeDescription
rfloat64Radius.
θfloat64Angle 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)}
Go Reference