Advertisement
smoke_th

Untitled

Apr 11th, 2021
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. import json
  2. import requests
  3. import csv  
  4. import numpy as np
  5. import vectormath as vmath
  6. import math
  7. #-368.03125 / -321.6875 / -1047.625
  8. v1 = vmath.Vector3(-368.03125, -321.6875, -1047.625)
  9. v2 = vmath.Vector3(142.65625 , 56.46875 , 40.34375)
  10. v3 = (v1-v2)
  11. v3.normalize()
  12. print(v3)
  13. total=[]
  14. for vinc in range(0, 180,1):
  15.     print('iterating '+str(vinc+1)+ ' out of 180')
  16.     vC=v1+(v3*float(vinc))
  17.     #vC.x=math.floor(vC.x)
  18.     #vC.y=math.floor(vC.y)
  19.     #vC.z=math.floor(vC.z)
  20.     print(vC)
  21.     PARAMS={'x':vC.x, 'y':vC.y, 'z': vC.z, 'radius':50,
  22.     'showCoordinates':1, 'showId':1, 'showInformation':1,
  23.     'showPrimaryStar':1}
  24.     v = requests.get('https://www.edsm.net/api-v1/cube-systems', params=PARAMS)
  25.     cdat=v.json()
  26.     #fakelambda
  27.     #if not any(d['name'] == cell['name'] for d in total):
  28.     for cell in cdat:
  29.         hasDupe=0
  30.         for tc in total:
  31.             if tc['name']==cell['name']:
  32.                 hasDupe=1
  33.                 break
  34.         if hasDupe==0:
  35.             total.append(cell)
  36.  
  37. csvw = open('extraTeresticles_Hesperus_WalkingSearch.csv', mode='w')
  38. writer = csv.writer(csvw, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL, lineterminator = '\n')
  39. writer.writerow(['system','Center Distance', 'x', 'y', 'z', 'id'])
  40. for cell in v.json():
  41.     #if cell['primaryStar']['type']=="K (Yellow-Orange) Star" and cell['bodyCount']>1:
  42.     writer.writerow([cell['name'], cell['distance'], cell['coords']['x'], cell['coords']['y'], cell['coords']['z'], cell['id']])
  43.  
  44. csvw.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement