In [52]:
from random import random
import numpy as np
import numpy.linalg as linalg
import scipy.spatial.distance as distance
def get_random_point_on_circle(radius=1., center=[0., 0.], constraint_circle_radius=18., constraint_circle_center=[0., 0.]):
    angle = random() * np.pi * 2
    xr, yr = (np.cos(angle) * radius + center[0], np.sin(angle) * radius + center[1])
    if constraint_circle_radius is not None:
        while distance.euclidean((xr, yr), tuple(constraint_circle_center)) > constraint_circle_radius:
            angle = random() * np.pi * 2
            xr, yr = (np.cos(angle) * radius + center[0], np.sin(angle) * radius + center[1])
    return xr, yr, angle

In [79]:
import matplotlib.pyplot as plt

points = [get_random_point_on_circle(radius=20, center=[5, -7])[0:2] for _ in range(100)]
xs, ys = np.transpose(points)

plt.scatter(xs, ys)
plt.show()

print(points[0:10])


[(-9.0071516260617734, 7.2758433489764442), (-14.999841548641331, -7.0796117405912558), (8.5836734040850935, 12.676312788041695), (12.316565513361692, 11.613647388104418), (-14.549017924013018, -2.7767431753896599), (-13.960989328688445, -0.6375410667444843), (-1.50613317898046, 11.91217150560373), (-14.993833443049041, -7.4966127783431009), (-12.534913492328137, 2.6190856538742135), (0.87374547197568475, 12.569722112742397)]

In [80]:
accepted = [(-13.251246367295806, 1.1787533304453888), (-7.7222205888245874, 8.431950728578931), (0.87374547197568475, 12.569722112742397), (-14.720895407423896, -3.6703927664892539), (12.825414533708608, 11.405512418175761)]
xs, ys = np.transpose(accepted)

plt.scatter(xs, ys)
plt.show()

print(points[0:5])


[(-9.0071516260617734, 7.2758433489764442), (-14.999841548641331, -7.0796117405912558), (8.5836734040850935, 12.676312788041695), (12.316565513361692, 11.613647388104418), (-14.549017924013018, -2.7767431753896599)]

In [54]:
accepted = [(-13.251246367295806, 1.1787533304453888), (-7.7222205888245874, 8.431950728578931), (-0.93943111587261185, 12.097726514425851), (-14.720895407423896, -3.6703927664892539), (12.825414533708608, 11.405512418175761)]
xs, ys = np.transpose(accepted)

orient_ps = [get_random_point_on_circle(radius=1., center=[x, y], constraint_circle_radius=None) for x, y in accepted]

plt.scatter(xs, ys)
plt.scatter(*np.transpose(orient_ps)[0:2], c='r')
plt.show()

print(points[0:5])


[(-13.251246367295806, 1.1787533304453888), (-7.7222205888245874, 8.431950728578931), (-0.93943111587261185, 12.097726514425851), (-14.720895407423896, -3.6703927664892539), (-14.101318220705313, -1.0721300426416853)]

In [59]:
print(np.transpose(orient_ps)[2])


[ 1.12384017  1.23160284  0.49253471  5.11085802  5.024955  ]

In [82]:
accepted = [(-13.251246367295806, 1.1787533304453888), (-7.7222205888245874, 8.431950728578931), (0.87374547197568475, 12.569722112742397), (-14.720895407423896, -3.6703927664892539), (12.825414533708608, 11.405512418175761)]
xs, ys = np.transpose(accepted)

ax = plt.subplot()

ax.scatter(xs, ys)
ax.scatter(*np.transpose(orient_ps)[0:2], c='r')
ax.scatter([5], [-7], c='k')
import pylab #Imports matplotlib and a host of other useful modules
cir1 = pylab.Circle((0,0), radius=18, alpha=.2, fc='y') #Creates a patch that looks like a circle (fc= face color)
cir2 = pylab.Circle((5,-7), radius=20, alpha =.2, fc='b') #Repeat (alpha=.2 means make it very translucent)
ax.add_patch(cir1) #Grab the current axes, add the patch to it
ax.add_patch(cir2) #Repeat
ax.set_xlim(-20, 20)
ax.set_ylim(-20, 20)
ax.set_aspect('equal')
ax.axhline(y=0, color='k')
ax.axvline(x=0, color='k')
plt.show()



In [ ]: