Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- p = 13
- q = 4 #p // 2
- try:
- rx, ry, rw, rh = map(int, input().split())
- #rx, ry, rw, rh = (0, 0, 100, 100)
- except:
- sys.exit(0)
- def intersection(s1, s2):
- x1, y1 = s1[0]
- x2, y2 = s1[1]
- x3, y3 = s2[0]
- x4, y4 = s2[1]
- d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
- if d == 0:
- return None
- return (((x1*y2 - y1*x2) * (x3 - x4) - (x1 - x2) * (x3*y4 - y3*x4)) / d,
- ((x1*y2 - y1*x2) * (y3 - y4) - (y1 - y2) * (x3*y4 - y3*x4)) / d)
- # all points on the circle
- pts = [(sin(x), -cos(x)) for x in (2*pi / p * i for i in range(p))]
- shift_list = lambda l, x: l[x:] + l[:x]
- forward_segments = list(zip(pts, shift_list(pts, q)))
- backward_segments = shift_list(forward_segments, len(forward_segments) // 2 + 4)
- internal_pts = map(intersection, forward_segments, backward_segments)
- all_pts = [ (int(round(rx + x * rw / 2)),
- int(round(ry + y * rh / 2)))
- for pair in zip(pts, internal_pts) for (x, y) in pair ]
- res_str = ' '.join((str(x) for pair in all_pts for x in pair))
- print(res_str)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement