Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import math
  2.  
  3. class Vector2:
  4.     x = 0
  5.     y = 0
  6.  
  7.     def __init__(self, x, y):
  8.         self.x = x
  9.         self.y = y
  10.  
  11.     def __repr__(self):
  12.         return f'[{self.x:.2f},{self.y:.2f}]'
  13.  
  14. def cross_2(u, v):
  15.     return u.x * v.y - u.y * v.x
  16.  
  17. num_of_iteration = 10
  18.  
  19. for i in range(num_of_iteration):
  20.     u_x = (i - num_of_iteration / 2) / num_of_iteration * 2
  21.     u_y = math.sqrt(1-u_x*u_x)
  22.     u = Vector2(u_x, u_y)
  23.     for j in range(num_of_iteration):
  24.         v_x = (j - num_of_iteration / 2) / num_of_iteration * 2
  25.         v_y = math.sqrt(1-v_x*v_x)
  26.         v = Vector2(v_x, v_y)
  27.         cross = cross_2(u, v)
  28.         print(f'{u} x {v} = {cross}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement