Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from numpy import linalg
- from pyglet.gl import *
- from pyglet.window import mouse
- print('Unesite koordinate ocista: ')
- ociste = np.array([int(x) for x in input().split()])
- print('Unesite koordinate gledista: ')
- glediste = np.array([int(x) for x in input().split()])
- lista_vrhova = []
- while True:
- print('Unesite sljedeci vrh poligona (prazno za kraj): ')
- line = input()
- if (len(line) == 0):
- print('Kraj')
- break
- v = np.array([int(x) for x in line.split()])
- lista_vrhova.append(v)
- print(lista_vrhova)
- x0, y0, z0 = ociste[0], ociste[1], ociste[2]
- T1 = np.array([[1, 0, 0, 0],
- [0, 1, 0, 0],
- [0, 0, 1, 0],
- [-x0, -y0, -z0, 1]])
- z = np.array([glediste[0] - x0, glediste[1] - y0, glediste[2] - z0])
- print(z)
- z = z / linalg.norm(z)
- print(z)
- viewUp = np.array([0, 1, 0])
- viewUp = viewUp / linalg.norm(viewUp)
- x = np.cross(z, viewUp)
- y = np.cross(x, z)
- R = np.array([[x[0], y[0], z[0], 0],
- [x[1], y[1], z[1], 0],
- [x[2], y[2], z[2], 0],
- [0, 0, 0, 1]])
- Tz = np.array([[1, 0, 0, 0],
- [0, 1, 0, 0],
- [0, 0, -1, 0],
- [0, 0, 0, 1]])
- Tuk = np.matmul(T1, R)
- Tuk = np.matmul(Tuk, Tz)
- print(Tuk)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement