Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import numpy as np
- import math
- URL = 'https://api.arstand-lab.ru'
- token = 'Token 581314b5dc6db4dd928dc249bf390affbec4df75'
- HEADERS = {'Authorization': token}
- def get_faces_npz():
- res = requests.get(f'{URL}/api/0/task/get_task/pyramid_faces_projections',
- headers=HEADERS)
- if res.ok:
- with open('file.npz', 'wb') as f:
- f.write(res.content)
- return True
- else:
- print(res)
- return False
- def post_faces_projections_npz(file_path):
- files = {'answer': open(file_path, 'rb')}
- res = requests.post(f'{URL}/api/0/task/check_task/pyramid_faces_projections',
- headers=HEADERS, files=files)
- if res.ok:
- return True
- else:
- print(res)
- return False
- def getPoint(x,y,z,x1,y1,z1):
- t = math.sqrt((x-x1)**2 + (y-y1)**2 + (z-z1)**2)
- l = (x1 - x)/t
- m = (y1 - y)/t
- n = (z1 - z)/t
- return -1*z*l/n, -1*z*m/n, 0
- Points = list()
- MetaPoints = list()
- v1 = 0
- if __name__ == '__main__':
- print('GET successful: ', get_faces_npz())
- a = np.load('file.npz')
- x,y,z = a['projector']
- for i in range(len(a['xyz_faces'])):
- Points = list()
- for y in range(4):
- kekes = list()
- np.save('example_1', a['xyz_faces'][i][y])
- b = np.load('example_1.npy')
- for v in range(len(b)):
- if b[v][2]>0:
- print(b[v][0], b[v][1], b[v][2])
- x1,y1,z1 = getPoint(x,y,z,b[v][0],b[v][1],b[v][2])
- b[v] = x1,y1,z1
- kekes.append(b[v])
- Points.append(kekes)
- MetaPoints.append(Points)
- np.savez('file.npz', answer=MetaPoints)
- print('POST successful: ', post_faces_projections_npz('file.npz'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement