summaryrefslogtreecommitdiff
path: root/libgo/go/cmath/rect.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/cmath/rect.go')
-rw-r--r--libgo/go/cmath/rect.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/libgo/go/cmath/rect.go b/libgo/go/cmath/rect.go
new file mode 100644
index 000000000..b955f0bf7
--- /dev/null
+++ b/libgo/go/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)
+}