* wpylib.math: Added complex_polar().

This commit is contained in:
Wirawan Purwanto
2013-12-09 17:27:44 -05:00
parent 093b15085b
commit f0ba6f4068

View File

@@ -85,3 +85,11 @@ def choose(n,r):
for (num,denom) in zip(xrange(n,n-r,-1), xrange(1,r+1,1)):
c = (c * num) // denom
return c
def complex_polar(r, theta):
"""Generates regular complex data (scalar or array) from
an input magnitude and angle."""
from numpy import sin, cos
# This way will be friendly for arrays:
return r * cos(theta) + 1j * r * sin(theta)