| 22 | sys.stdin.__class__.__name__ == 'PyShell' |
| 23 | |
| 24 | class transformer: |
| 25 | |
| 26 | def __init__(self, world, viewport): |
| 27 | self.world = world |
| 28 | self.viewport = viewport |
| 29 | |
| 30 | def point(self, x, y): |
| 31 | x_min, y_min, x_max, y_max = self.world |
| 32 | X_min, Y_min, X_max, Y_max = self.viewport |
| 33 | f_x = float(X_max-X_min) /float(x_max-x_min) |
| 34 | f_y = float(Y_max-Y_min) / float(y_max-y_min) |
| 35 | f = min(f_x,f_y) |
| 36 | x_c = 0.5 * (x_min + x_max) |
| 37 | y_c = 0.5 * (y_min + y_max) |
| 38 | X_c = 0.5 * (X_min + X_max) |
| 39 | Y_c = 0.5 * (Y_min + Y_max) |
| 40 | c_1 = X_c - f * x_c |
| 41 | c_2 = Y_c - f * y_c |
| 42 | X = f * x + c_1 |
| 43 | Y = f * y + c_2 |
| 44 | return X , Y |
| 45 | |
| 46 | def twopoints(self,x1,y1,x2,y2): |
| 47 | return self.point(x1,y1),self.point(x2,y2) |
| 48 | |
| 49 | class clock: |
| 50 | |