To run the following code you need scipy to be installed. The raw file which can be executed in the bash can be downloaded here: scipy_example.py
%matplotlib inline
import numpy as np
from numpy import linalg as LA
import pylab
def circle(Sx, Sy, r0, phi):
return np.array([Sx + r0*np.cos(phi), Sy + r0*np.sin(phi)])
def P(Sx, Sy, r0, phi):
return np.array([Sx + r0*np.cos(phi),
Sy + r0*np.sin(phi)])/LA.norm(np.array([Sx + r0*np.cos(phi), Sy + r0*np.sin(phi)]))
def picture1(Sx, Sy, r0, phi):
return P(Sx, Sy, r0, phi) * np.sin(4.*phi)
PhiList = np.linspace(0, 2*np.pi, 1000) # 100 evenly-spaced values from 0 to 50
SX = 0
SY = 0
R0 = 1
steps = 1000
pointlist1 = [circle(0,0,1,phi) for phi in np.linspace(0, 2*np.pi, steps)]
pointlist2 = [picture1(SX, SY, R0, phi) for phi in np.linspace(0, 2*np.pi, steps)]
pylab.xlabel('x')
pylab.ylabel('y')
pylab.axes().set_aspect('equal')
pylab.grid(True)
pylab.plot( *zip(*pointlist1), linestyle="--")
pylab.plot( *zip(*pointlist2))