SHARE
TWEET

Untitled

a guest May 19th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. from numpy import linalg
  3.  
  4. from pyglet.gl import *
  5. from pyglet.window import mouse
  6.  
  7. print('Unesite koordinate ocista: ')
  8. ociste = np.array([int(x) for x in input().split()])
  9. print('Unesite koordinate gledista: ')
  10. glediste = np.array([int(x) for x in input().split()])
  11. lista_vrhova = []
  12.  
  13. while True:
  14.     print('Unesite sljedeci vrh poligona (prazno za kraj): ')
  15.     line = input()
  16.     if (len(line) == 0):
  17.         print('Kraj')
  18.         break
  19.     v = np.array([int(x) for x in line.split()])
  20.     lista_vrhova.append(v)
  21. print(lista_vrhova)
  22.  
  23. x0, y0, z0 = ociste[0], ociste[1], ociste[2]
  24.  
  25. T1 = np.array([[1, 0, 0, 0],
  26.                [0, 1, 0, 0],
  27.                [0, 0, 1, 0],
  28.                [-x0, -y0, -z0, 1]])
  29.  
  30. z = np.array([glediste[0] - x0, glediste[1] - y0, glediste[2] - z0])
  31. print(z)
  32. z = z / linalg.norm(z)
  33. print(z)
  34.  
  35. viewUp = np.array([0, 1, 0])
  36. viewUp = viewUp / linalg.norm(viewUp)
  37.  
  38. x = np.cross(z, viewUp)
  39. y = np.cross(x, z)
  40.  
  41. R = np.array([[x[0], y[0], z[0], 0],
  42.               [x[1], y[1], z[1], 0],
  43.               [x[2], y[2], z[2], 0],
  44.               [0, 0, 0, 1]])
  45.  
  46. Tz = np.array([[1, 0, 0, 0],
  47.                [0, 1, 0, 0],
  48.                [0, 0, -1, 0],
  49.                [0, 0, 0, 1]])
  50.  
  51. Tuk = np.matmul(T1, R)
  52. Tuk = np.matmul(Tuk, Tz)
  53. print(Tuk)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top