コード例 #1
0
from math import e, pi
from plotting import plot2

n = 20


def comp(inp):
    if inp:
        return (2 * pi) / inp
    else:
        return 0


def ei_comp(x):
    cm = e**complex(0, comp(x))
    return cm.real, cm.imag


pts = [ei_comp(x) for x in range(n)]
plot2(pts, rev=False)
コード例 #2
0
curr_dir = os.getcwd()
image_path = '%s/img01.png' % curr_dir

print 'Checking...%s' % image_path
if os.path.isfile(image_path):

    print 'Using png image...'

    data = image.file2image(image_path)
    height = len(data)
    width = len(data[0])

    # First get points from image
    pts = {
        x - 1j * y
        for y in range(height) for x in range(width) if max(data[y][x]) < 120
    }

    # Next centre points.
    pts = {(c.real - width * 0.5) + (c.imag + height * 0.5) * 1j for c in pts}

    # Now rotate by pi/4.
    pts = [c * (e**complex(0, (pi / 4))) for c in pts]

    # Plot.
    plot2(pts, range=280)

else:
    print 'Image path not found. Aborting.'
コード例 #3
0
from plotting import plot2

cm_set = set([(3 + 1j), (2 + 2j)])
#cm_set = set([(-1+2j), (1-1j)])
#cm_set = set([(2+0j), (-3+0.001j)])
#cm_set = set([(0+2j), (0.001+1j)])

print 'cm_set', cm_set
cm_set_add = complex()
for c in cm_set:
    cm_set_add = cm_set_add + c

cm_set.add(cm_set_add)

print cm_set

plot2(cm_set)
コード例 #4
0
print 'L'
L = \
[(6+3.30789538039j),
(4+2.10735964129j),
(3+7.83487879415j),
(108+4.46941876974j),
(90+7.65527467896j),
(42+10.4434009298j),
(42+14.3005419538j),
(152+8j),
(189+9j),
(80+13.8544970565j)]
pprint(L)

from plotting import plot2
plot2(L)

# 1.7.12
#result = transform(a, b, L)
#print 'result'
#pprint(result)
#plot2(result)

# 1.7.12a
def transform2(L):
	result = []
	for c in L:
		c = complex(1, 1) + c   # move 1, 1
		c = pow(e, complex(0, pi*0.5)) * c   # rotate clockwise 90
		c = c * 2	# scale x2
		result.append(c)
コード例 #5
0
from math import e, pi
from plotting import plot2

S = {
    2 + 2j, 3 + 2j, 1.75 + 1j, 2 + 1j, 2.25 + 1j, 2.5 + 1j, 2.75 + 1j, 3 + 1j,
    3.25 + 1j
}

a = pi / 4.0

pts = [c * (e**complex(0, (pi / 4))) for c in S]

plot2(pts, range=6)
コード例 #6
0
from plotting import plot2

def segment(pt1, pt2, segments=100):
	pt1_inc = (pt2[0] - pt1[0]) / segments
	pt2_inc = (pt2[1] - pt1[1]) / segments
	pts = []
	for i in range(segments):
		pts.append((pt1[0]+(i*pt1_inc), pt1[1]+(i*pt1_inc)))
	return pts

pts = segment([3.5, 3], [0.5, 1.0])
print len(pts)
plot2(pts)
コード例 #7
0
import image
import os
from pprint import pprint
from plotting import plot2

curr_dir = os.getcwd()
image_path = '%s/img01.png' % curr_dir

print 'Checking...%s' % image_path
if os.path.isfile(image_path):

    print 'Using png image...'

    data = image.file2image(image_path)
    width = len(data)
    height = len(data[0])
    pts = {
        -1j * x + y
        for x in range(width) for y in range(height) if max(data[x][y]) < 120
    }
    plot2(pts, range=200)

else:
    print 'Image path not found. Aborting.'