From d87b31275169e4a1e37c8cbe07decf4e0e59b2ca Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Fri, 20 Jun 2014 16:29:45 +0300 Subject: [PATCH] Constellation design --- constellation.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 constellation.py diff --git a/constellation.py b/constellation.py new file mode 100644 index 0000000..1ea6d68 --- /dev/null +++ b/constellation.py @@ -0,0 +1,24 @@ +import numpy as np + +def points(minR, maxR): + minR = float(minR) + maxR = float(maxR) + n = int(maxR) + I = range(-n, n+1) + P = [x + 1.0j*y for x in I for y in I] + P = np.array([p for p in P if (minR <= abs(p) and abs(p) <= maxR)]) + return P / maxR + +if __name__ == '__main__': + import pylab + import sys + r, R = sys.argv[1:] + p = points(r, R) + pylab.plot(p.real, p.imag, '.') + pylab.title(str(len(p))) + c = np.exp(2j*np.pi*np.linspace(0, 1, 1000)) + pylab.plot(c.real, c.imag, ':') + pylab.grid('on') + pylab.axis('equal') + pylab.show() +