-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathKPS_GenPoly.py
104 lines (86 loc) · 2.89 KB
/
KPS_GenPoly.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3.4
####################################################################
# KPS_GenPoly.py
# KPS
#
# Author: Kareem Omar
# kareem.omar@uah.edu
# https://github.com/komrad36
#
# Last updated Feb 27, 2016
# This application is entirely my own work.
####################################################################
#
# Generates a polygon configuration file for input to the KPS
# propagation framework. The idea is that users can modify this script,
# or copies of it, to be arbitrarily complex, allowing easy modification
# of a parameter such as a solar panel deployment angle without having to
# manually recompute numerical values for all vertices.
#
# For example, this script currently writes a 6U "dart" configuration
# satellite, and rather than having to manually compute vertices based
# on the panel length and angle, simply modify the 'H' and 'PA' variables
# and run this script to generate the updated polygon file.
#
# Verify correct polygon generation with KPS_PlotPoly.
#
from math import sin, cos, pi
from sys import argv
num_vtx = 4
# folding panel length [m]
H = 0.3
# panel angle
PA = 130.0 / 180.0 * pi
# header string to go at the top of the output polygon file
header = '# 6U Dart\n# Panel Length: ' + str(H) + '\n# Panel Angle: ' + str(180/pi*PA)
# The actual body frame satellite as a series of polygons.
# This is a 6U 'dart' configuration facing in the +z with all 4 panels
# bilaterally symmetrically deployed to the panel angle specified above.
poly = [\
[0.1, -0.05, -0.15],
[0.1, 0.05, -0.15],
[0.1, 0.05, 0.15],
[0.1, -0.05, 0.15],
[-0.1, -0.05, -0.15],
[-0.1, 0.05, -0.15],
[-0.1, 0.05, 0.15],
[-0.1, -0.05, 0.15],
[-0.1, 0.05, -0.15],
[0.1, 0.05, -0.15],
[0.1, 0.05, 0.15],
[-0.1, 0.05, 0.15],
[-0.1, -0.05, -0.15],
[0.1, -0.05, -0.15],
[0.1, -0.05, 0.15],
[-0.1, -0.05, 0.15],
[-0.1, -0.05, 0.15],
[0.1, -0.05, 0.15],
[0.1, 0.05, 0.15],
[-0.1, 0.05, 0.15],
[-0.1, -0.05, -0.15],
[0.1, -0.05, -0.15],
[0.1, 0.05, -0.15],
[-0.1, 0.05, -0.15],
[0.1, 0.05, -0.15],
[0.1, -0.05, -0.15],
[0.1 + H * sin(PA), -0.05, -0.15 + H * cos(PA)],
[0.1 + H * sin(PA), 0.05, -0.15 + H * cos(PA)],
[-0.1, 0.05, -0.15],
[-0.1, -0.05, -0.15],
[-0.1 - H * sin(PA), -0.05, -0.15 + H * cos(PA)],
[-0.1 - H * sin(PA), 0.05, -0.15 + H * cos(PA)],
[0.1, 0.05, -0.15],
[-0.1, 0.05, -0.15],
[-0.1, 0.05 + H * sin(PA), -0.15 + H * cos(PA)],
[0.1, 0.05 + H * sin(PA), -0.15 + H * cos(PA)],
[0.1, -0.05, -0.15],
[-0.1, -0.05, -0.15],
[-0.1, -0.05 - H * sin(PA), -0.15 + H * cos(PA)],
[0.1, -0.05 - H * sin(PA), -0.15 + H * cos(PA)]]
if len(argv) != 2:
print('\nUsage: KPS_GenPoly.py <outfile>\n')
else:
# write polygons to file
with open(argv[1], 'w') as f:
f.writelines(tuple(header) + tuple('\n') + tuple(('' if i % num_vtx else '\n') + ', '.join(str(x) for x in poly[i]) + '\n' for i in range(len(poly))))
print('\nSuccessfully wrote ' + argv[1] + '.\n')