Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cosine_polyline(pdf, x0, y0, x1, y1, orientation):
- N = 32
- x_points = []
- y_points = []
- if orientation == horizontal:
- w = (x1 - x0)
- h = 0.5 * (y1 - y0)
- y_avg = 0.5 * (y0 + y1)
- elif orientation == vertical:
- w = 0.5 * (x1 - x0)
- h = (y1 - y0)
- x_avg = 0.5 * (x0 + x1)
- else:
- raise Exception()
- for i in range(0, N + 1):
- frac = float(i) / N
- angle = math.pi * frac
- if orientation == horizontal:
- x = x0 + w * frac
- y = y_avg + h * math.cos(angle)
- elif orientation == vertical:
- x = x_avg - w * math.cos(angle)
- y = y0 + h * frac
- else:
- raise Exception()
- x_points.append(x)
- y_points.append(y)
- pdf.draw_polyline(x_points, y_points)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement