summaryrefslogtreecommitdiff
path: root/src/pkg/cmath/rect.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/cmath/rect.go')
-rw-r--r--src/pkg/cmath/rect.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pkg/cmath/rect.go b/src/pkg/cmath/rect.go
new file mode 100644
index 000000000..b955f0bf7
--- /dev/null
+++ b/src/pkg/cmath/rect.go
@@ -0,0 +1,13 @@
+// Copyright 2010 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 cmath
+
+import "math"
+
+// Rect returns the complex number x with polar coordinates r, θ.
+func Rect(r, θ float64) complex128 {
+ s, c := math.Sincos(θ)
+ return complex(r*c, r*s)
+}