Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- class Vector2:
- x = 0
- y = 0
- def __init__(self, x, y):
- self.x = x
- self.y = y
- def __repr__(self):
- return f'[{self.x:.2f},{self.y:.2f}]'
- def cross_2(u, v):
- return u.x * v.y - u.y * v.x
- num_of_iteration = 10
- for i in range(num_of_iteration):
- u_x = (i - num_of_iteration / 2) / num_of_iteration * 2
- u_y = math.sqrt(1-u_x*u_x)
- u = Vector2(u_x, u_y)
- for j in range(num_of_iteration):
- v_x = (j - num_of_iteration / 2) / num_of_iteration * 2
- v_y = math.sqrt(1-v_x*v_x)
- v = Vector2(v_x, v_y)
- cross = cross_2(u, v)
- print(f'{u} x {v} = {cross}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement