Approximation Techniques for the Optimal Scheduling by

Approximation Techniques for the Optimal Scheduling
of the Space-Based Visible Satellite
by
Paul T. Czerniak
Xvcn QOCYI
Submitted to the Department of Electrical Engineering and Computer Science
in Partial Fulfillment of the Requirements for the Degree of Bachelor of Science in
Electrical Engineering and Computer Science and Master of Engineering in Electrical
Engineering and Computer Science at the Massachusetts Institute of Technology
OF TECHNOLOGY
MASSACHUSETS
INSTITUTE
) Copyright 2000 MIT
_
.
All rights reserved.
JUL 27 2000
LIBRARIES
A
Diep.fmfent of Electrical Engineering and Computer Science
May 22, 2000
Certified h
Paul E. Gray
es
uctrical Engineering, President Emeritus
T s Supervisor
Accepted by
(
Pro . Arthur C. Smith
Chairman, Department Committee on Graduate Theses
Acknowledgements
The author would like to thank the following people for their assistance and support,
without whom none of this would have been possible: (in alphabetical order):
Willaim Burnham - MIT Lincoln Laboratory
Robert and Nancy Czerniak
Kathleen Ennis
Prof. Paul Gray - MIT
Prof. Leslie Pack Kaelbling - MIT
Raymond LeClair - MIT Lincoln Laboratory
Dr. Ramaswamy Sridharan - MIT Lincoln Laboratory
2
Table of Contents
I.
II.
Abstract
Introduction
III.
Current Approach: Greedy, One-Step Look Ahead Algorithm
1. Overview
2. Figure of merit
3. Evaluation of current approach
IV.
Paradigm Shift
1. Previous methods in approximation
a. Traveling Salesman comparison
b. Other approaches
2. New paradigm: randomized improvement
V.
Predicting Satellite Locations
1. Stage 1: Checking/loading the element sets
a. Definition of an element set
b. Method for checking/loading element sets
2. Stage 2: Propagating a satellite in its orbit
a. Finding the mean anomaly
b. Newton's method for Kepler's equation
c. Eccentric anomaly to (x,y,z) position
VI.
Planning the SBV Observation Path
1. Modeling the iteration Process
2. Determining valid satellite targets
a. Earth constraint
b. Sun constraint
3. Specifying SBV orientation
4. Simulation
VII.
VIII.
IX.
X.
Results
Conclusions
References
Appendices
1. Explanation of coding modules
2. Included code
3
Approximation Techniques for the Optimal Scheduling
of the Space-Based Visible Satellite
by
Paul T. Czerniak
Submitted to the Department of Electrical Engineering and
Computer Science of the Massachusetts Institute of Technology
May 22, 2000
In Partial Fulfillment of the Requirements for the Degree of
Bachelor of Science in Electrical Engineering and Computer
Science and Master of Engineering in Electrical Engineering and
Computer Science
Abstract
A new approach to scheduling the Space-Based Visible (SBV) satellite is proposed,
with an emphasis on incremental random improvements to schedules obtained by current
approximation algorithms. A detailed model of orbit propagation is presented to simulate
this current approach: a one-step look ahead, greedy algorithm. Simulation of the greedy
algorithm and an iterative improvement algorithm then demonstrate that the proposed
incremental improvement strategy does yield improvements in some cases.
Thesis Supervisor: Paul E. Gray
Title: Professor of Electrical Engineering, President Emeritus, MIT
4
Introduction
The Space-Based Visible (SBV) satellite is used in conjunction with other forms of
detection (ground radar, etc.) to fulfill the U.S. Air Force's congressional mandate to
monitor all satellites currently in orbit (hereafter denoted target satellites for clarity). The
SBV utilizes four charge-coupled device imagers (CCD's) to obtain visual information
on the various target satellites. These imagers each give a 1.4* by 1.4' field of view, and
are mounted in a linear orientation. While the SBV can only capture data from one
imager at a time, the four CCD's are effectively acting as one imager, providing a 1.4' by
5.60 field of view. Further, any satellite within the field of view during the data capture
operation of the imager can be identified and recorded.
The SBV satellite is in operation for approximately 8 hours each day, collecting
information from its field of view. The SBV, however, is not controlled in real-time.
Instead, the commands for this 8-hour period are determined and uploaded before the
satellite begins its sequence of operations. This is not a problem, however, as
sophisticated programs exist to accurately predict the location of a target satellite when
given information about its current orbit. Thus, one can plan the 8-hour surveillance of
the various target satellites using previous measurements.
The problem then becomes how to schedule the various operations, given that one can
predict the orbits of the individual target satellites with good accuracy, such that the
amount of data that is obtained from the 4 CCD's is maximized. That is to say, we are
interested in deciding how the SBV should be oriented at each point in time, as it goes
through its given orbit. This sequence of orientations, denoted "SBV path", should be set
to maximize the observations of the target satellites.
This paper will analyze the current
5
method of finding this SBV path of observations, and explain why further investigation
into a better single algorithm for a candidate path might not be the best method for
gaining significant improvement. However, if the attention is turned from finding the
best possible overall path or "global optimum", and only to improving a given SBV path
of observations, then randomized, incremental-improvement algorithms might be able to
succeed.
Current Approach: Greedy, One-Step Look Ahead Algorithm
Overview:
Currently, the SBV satellite operations are scheduled through the use of a "greedy",
"one-step look ahead" algorithm, as the approach is known. This algorithm determines
an optimal path in the following manner. First, a starting time (to) is chosen for the path
of observations, and all of the target satellite positions are calculated at that particular
time. Then, a set of candidate orientations for the SBV is determined. This is done by
grouping the visible target satellites (those that are not blocked by the earth, sun, etc.)
into fields of view of the SBV imagers.
Then, each realizable orientation of the SBV satellite is assigned a figure of merit.
This is basically a metric that one uses to compare the relative benefit of one orientation
of the SBV when compared with another, and will be discussed further in the next
section. The SBV orientation that maximizes the figure of merit is then chosen for the
SBV path at to.
6
Once the first SBV orientation has been established, we continue by finding the next
orientation in the SBV path. This is accomplished by again maximizing the figure of
merit over all of the candidate SBV orientations. Note that the figure of merit for the
various SBV orientations will have changed as time progresses. We continue this process
until we have reached a preset ending time (tf), which is usually a path of about 8 hours in
length for the SBV. Table 1 represents a sample of a possible result for the SBV path
after using this current approach.
Table 1: Result of Greedy Algorithm
Start(to)
Time
Possible Orientations:
Orientation # used:
Figure of Merit:
ti
tfrI
End (tf)
5:34 AM
5:37 AM
...
1:31 PM
1:34PM
612
123
143
234
211
234
...
...
523
316
121
845
845
90
...
The values shown are arbitrary, but convey the point that we are not comparing the
figure of merit at different times to find the maximum, only comparing among candidates
for the orientation at each single step. Thus, at to,we have 612 possible orientations, with
orientation #123 having the highest figure of merit of the group with a value of 143. We
then find the next orientation simply be comparing the 234 possible follow-up operations
against each other, and pick the result (here, orientation #211) that again maximizes the
figure of merit. The fact that we are only considering the orientations at each single step
is what gives this approach the title "one-step look ahead," and the choice of the
orientation that maximizes the figure of merit at each point in the path is considered a
''greedy" strategy.
7
Choosing Figure of Merit:
The figure of merit is therefore a very important factor in determining the eventual
path that will be returned for the SBV. This figure of merit can be calculated based on a
variety of factors, including, but not limited to:
1.
To maximize the number of observations in a given path, we would like to have
as many target satellites in the field of view at a given time as possible. The number of
target satellites that the SBV can view while focusing the field of view in a particular
orientation is thus included in the figure of merit of that orientation.
2. The amount of time that it would take to transition from the current orientation of
the SBV satellite to the orientation in question. This is not merely a calculation based on
angle, however. As stated in the SBV System Definition Document, "The MSX is a
satellite with severe thermal, power, and attitude constraints" (Harrison pg. 152). Thus,
due to all of the satellite constraints, the shortest path with which to rotate the SBV to
achieve a given orientation might not be feasible. However, an algorithm that uses
approximation heuristics to the satellite's constraints has been developed and can be used
to predict the transition time from one orientation to another. For every time other than
the start time to, we have an orientation that we must transition from in order to view a
new orientation. Thus, we can use the transition time as a factor when evaluating the
candidates for the next orientation in the resulting path. As far as the first orientation is
concerned, since the satellite is not gathering data for 16 hours previous to the start of the
observation path, we can simply use this down time to transition the SBV to any
8
orientation without penalty. Thus, when evaluating the first orientation, all transition
times are considered equal.
3.
Whether or not the target satellite has already been viewed in the day's
operations, as one would not want to use the SBV's resources to continually look at the
same set of satellites, even if such a path yielded the most total satellite images.
4. A priority that can be set by the US Air Force, etc. On some days, some target
satellites might be more important to view than others.
5. The range of time that a target satellite is detectable. If a satellite is important to
view (see #4) and will not be viewable in a certain time period (due to size of orbit, etc.),
then one might want to increase the figure of merit value for that particular satellite.
Evaluation of Current Algorithm
The benefit of the greedy, one-step look ahead algorithm is that it takes the process of
scheduling a sequence of events and condenses the problem to basically evaluating one
function on a set of possible orientations. The fact that each step is independent of future
events and, except for the transition time included in the figure of merit, free of all past
events, is highly beneficial. By separating the path into these distinct orientations and
then isolating them, the computational power required is greatly reduced. If one wanted
to compute even a short path by evaluating all of the combinations of all of the possible
orientations, one quickly runs into the problem of exponential growth. The following
graph (Figure 1) demonstrates the growth of the search space for paths of lengths 1 to
10:
9
I
Figure 1: Growth of Search Space
Growth of search space:
600 targetskound
10-
10
10
1010
10P
1
2
3
4
5
6
Depth of search
7
8
9
10
Since the average path of the SBV is around 120 separate orientations in length, the
computation time required to implement a global search of all combinations is not
currently computationally feasible.
Why would one want to evaluate all of the combinations of the SBV orientations?
After all, the figure of merit has already been maximized! Unfortunately, the problem is
not so simple. While a greedy approach does guarantee a local maximization of the
figure of merit, and effectively isolates the process of choosing each orientation from
choosing the other orientations, it does not account for the influence that a current choice
of observation will have on the availability of observations in the future. It is very
possible that a non-optimal choice at one time will allow for observations in the future
that were not included in the set of possible orientations when the locally-optimal choice
was taken.
As an example, suppose that the locally-optimal orientation at time t4 gives a figure of
merit of 100 now, and that when it is finished with that orientation, the maximum at t5
gives a figure of merit of 120. One can evaluate the figure of merit of the path as being
10
the sum of the orientations, therfore giving a path value of 220 for views 4 and 5. Now,
suppose that another orientation had existed at t4 with a figure of merit of 85. However,
by taking that orientation, the SBV was put into an position where it could get a new
orientation at t5 with a figure of merit of 140. Then, the new path has a figure of merit
total of 225, for a better solution. This is not considered with the greedy approach, and
thus the resulting path from the greedy algorithm could theoretically be much worse than
the globally optimized solution.
However, there do exist some problems for which the greedy strategy does give the
globally optimized solution. Consider the following problem posed by Cormen,
Leiserson, and Rivest (Cormen, 330): Suppose one wants to schedule a sequence of
events such that the highest number of events can be attended. If the events can occur
simultaneously, but can not be attended/done at the same time, how does one find the
schedule that maximizes the number of events?
The greedy approach is to sort the events by ending time, and choose at each iteration
the event that is the first to end without overlapping an event that has already been
picked. We can see that this is globally optimal as follows: consider the first event of the
path given by a globally optimal solution. If it is equal to the first event of the result of
the greedy strategy, then we are equal to optimal for this choice. If not, we know that our
choice ends sooner than the event that is first in the globally optimal list, due to the way
we picked our events! We can therefore replace the globally optimal choice with our
event and append the remaining segment of the globally optimized list. By continuing
this argument for each choice of event in the greedy strategy, we can conclude that the
greedy strategy is globally optimal.
11
We now see that while we are not guaranteed a globally optimal solution by using a
greedy, one-step look ahead algorithm for the SBV path, it is a possibility. Thus, to
analyze the effectiveness of the greedy algorithm approach, one would like to be able to
answer a few questions:
1.
How close to globally optimal is the result of the greedy algorithm?
2. If greedy algorithm is not optimal, can a globally optimized path be attained?
3. What kind of time improvement could a globally optimized list of operations give
over the current implementation? Is it worth the development cost?
4. If so, how would one go about calculating the various computations for the
orientations (in acceptable time limits)?
Paradigm Shift
Previous Methods in Approximation
In order to attempt to answer these questions, the following methods were examined.
First, to determine how close the greedy result was to the globally optimal path for the
SBV, it would be necessary to have a globally optimal path for comparison. However, as
we have previously seen from Figure 1, a brute force approach would take an
unacceptable amount of time to complete. Since at the moment we do not have another
method to compute a globally optimum path for the SBV, the next method is developing
different approaches to approximating the best SBV path, and comparing the final results
against each other to determine which is closer to a globally optimized solution.
12
Traveling Salesman Comparison:
In this spirit, a number of algorithmic approaches were examined in order to try and
approximate the globally optimal path for the SBV. The first group of approximation
algorithms comes from the comparison between the SBV viewing different satellites and
a traveling salesman attempting to visit different cities to sell a product. Thus, given a set
of cities and the distances between them, find the minimum length route that covers all of
the cities. Extensive research has been conducted on this "traveling salesman" problem,
with many approximation algorithms at the result. The general approach is to find a
"minimum-spanning tree" or a tree of minimum size that covers all of the vertices (in this
case satellites or cities) (Cormen, 970). Then, we can use the branches of this tree to find
a route that is at most a multiplicative factor of 2 worse than the optimal solution.
Further, this can be done as fast as we can find a minimum-spanning tree, which in this
case uses a version of Prim's algorithm, with a running time of O(V 2 ), where V is the
number of vertices. Thus, it seems as if we can find a good approximation quickly.
Unfortunately, however, the conversion to a traveling salesman problem is not so
simple. The task of scheduling the traveling salesman is just a step closer to our actual
problem than the event problem for which the greedy algorithm gave a globally optimal
solution. First, the "cities" or satellites in our problem are not of equal value. Thus, we
enter a new problem construct, known as a prize-collecting traveling salesman problem.
Here, the idea becomes that at each city the salesman can pick up a certain, pre-known
number of sales. He does not have time to visit all of the cities, so which ones does he
visit, and in what order?
13
This problem has also been given some treatment. As Awerbuch observes, this is
basically the same as finding a minimum-spanning tree on a subset of k cities in an n city
world (Awerbuch, 2). The problem is complicated in that now we aren't only concerned
with finding the minimum spanning tree, but also with deciding which cities to include.
This publication by Awerbuch gives a polynomial-time algorithm that guarantees a
O(log2(min(R,n))) bound on the deviation from optimality, with R as the minimum
number of items to be sold (if a quota is desired) and n the number of cities. This again
appears to give a usable result for our problem. Unfortunately, this comparison is not
exactly correct either. In the prize-collecting traveling salesman problem, the cities are
visitable at any time. However, with the sun and the earth constraints, a certain satellite
might not be viewable when this algorithm would like to schedule it.
This new branch of problem also has been examined, but to a lesser degree due to its
level of complexity. In an examination by Dumas, Desrosiers, and Gelinas, it is noted that
"While the research on time constrained routing problems has grown at an explosive rate,
research on the Traveling Salesman Problem with Time Windows has been scant.
Savelsbergh (1985) has shown that even finding a feasible solution is an NP-complete
problem" (Dumas, 1). Thus, if we could find a solution that would give a feasible path to
the entire problem in polynomial time (i.e. given n cities, find a path that goes through all
of the cities and meets the time bounds), we would be able to solve ANY problem in
polynomial time. While it is not a certainty that we cannot solve all problems in
polynomial time, it is very unlikely, so this type of problem is confined to the same
running time that we saw with the brute force approach earlier. This is before we add
prize-collection to the problem.
14
In response to this problem, various methods have been utilized. Christofides
heuristic uses the minimum-spanning tree with other assumptions to find a solution to the
traveling-salesman with time windows. Other methods (Dumas) have found ways to
narrow the search space by incorporating the time windows into a dynamic programming
algorithm. Unfortunately, no algorithm was found that addressed both the addition of the
prize-collection and the time-windows. As noted by Marcus Solomon "Almost all
approaches to the routing problem suffer from the limitation that they do not consider
time windows constraints" (Solomon, 1). Although this result is approximately 15 years
old at the time of this writing, it is the case that the time windows alone give a problem
(NP-complete, as discussed earlier) that is discouraging. The addition of prize-collection,
and the broad applicability begins to be lost while a lot of complexity is being added.
Further, we haven't yet included all of the constraints that make this problem
difficult! The final step is that the inter-city distance, which is fixed for the traveling
salesman problem (with/without prize collection or time windows), is now a variable!
Transitions from having satellite 1 in the field of view to having satellite 2 in the field of
view can take different amounts of time depending on when one wishes to transition, due
to the fact that the satellites are moving. Thus, what we can imagine is a salesman
attempting to sell his products in a set of cities, where he doesn't know which cities to
visit to maximize profits, where each city only exists for half of the day, and all of the
cities are moving around the world as he works. We can summarize this expansion of
the problem in the following table:
15
Table 2: Ranking of Difficulty of Problems (Easiest to Most Difficult)
Problem Statement
Algorithm for Solution
Simple Event Scheduling
Greedy Algorithm
Traveling Salesman
Minimum Spanning Tree
Prize-Collecting Traveling Salesman
Minimum Spanning Tree Variant
Traveling Salesman w/Time Windows
Heuristic Approach: NP-Complete
Prize-Collecting and Time Windows
-none-
SBV (including movement)
?????
This demonstrates that while the problems of scheduling such activities might seem
closely related to the SBV problem, there are major factors that separate them, and thus
the usefulness of these algorithmic comparisons to the SBV scheduling is not the simple
solution it might appear to be.
Other Algorithmic Approaches
When the traveling salesman approach did not yield any results, other attempts were
made to find a suitable algorithm for comparison with the greedy algorithm. One of the
suggested approaches included maximizing 7-dimensional line integrals through a space
defined by the 3 coordinates of the target satellites, time, and the coordinates of the SBV,
though how that would be attempted is not clear. Additionally, dynamic programming
was introduced, mappings and adjustments and assumptions of all kinds began to be
suggested as ways to make this problem more easily solvable.
16
The problem was that all of these solutions were very difficult, very computationally
demanding, and made many assumptions that would jeopardize the results. The simple
truth is that this is an NP-complete problem, with nothing to grab onto for a neat
algorithmic solution. Many algorithmic breakthroughs are made by exploiting some
hidden structure of the problem to allow for a good approximation, but this problem
seems to have no structure at all. Everything is a variable, and every variable is nonlinear (elliptical orbits, heuristic transition times, etc.).
New Paradigm: Randomized Improvement
After this sobering realization, the problem seems out of reach. However, Prof.
Leslie Pack Kaelbling, an Artificial Intelligence professor at MIT, had the following
reaction to the problem: why not try and use random modifications to incrementally
improve the path? The resulting incremental improvement can be executed as long as
one has time, and could guide the path toward a global optimum, if not eventually
achieving that goal.
The real issue here was one of a paradigm of approximation algorithms. Generally,
the idea is that given an input set of conditions, we would like an algorithm that gives a
result. How good a result depends on how good an algorithm we are able to invent, as
shown in Figure 2. We see that we have a set of positional data (i.e. the locations of all
of the satellites, etc.) that we need to plan a SBV orientation path. The traditional
approach is that we take this data and run it through an algorithm, such as the greedy
algorithm currently in use, or a traveling salesman approximation algorithm, etc. The
17
Fiure 2: Current Approach to Solving Problems
POSITIONAL DATA
Information about orbits received from
previous radar and satellite measurements.
ORBIT ALGORITHM
Apply deterministic algorithms to find candidate
paths for the SBV satellite. Ex: Local maximum
or greedy algorithm, distance heuristic.
Local maximum: A 11 A 2A 33A 5 A 45 A 34A8 8 A 44A6 5 ...
Distance heuristic: A 45A 6 5A 3A 34A22A 9A 77A5 5 A6 5 ...
Other heuristics: A1 A 2A 3A 34A 10 A A 8A 44 4A6 6 4 ...
result of this algorithm will be a path for the SBV, which is denoted in the figure as a
sequence of satellite orientations (where A34 is the satellite in an orientation centered on
target satellite 3, with target satellite 4 specifying the rotation. This will be clarified in
the later section on modeling). The most important concept, however, is that the result
from the different deterministic algorithms will be different SBV paths, and that the
"value" of each path is based on the effectiveness of the algorithm that produced it.
This is a good approach to solving many problems, but what happens when a good
deterministic algorithm is currently unknown? It is very possible that one exists, but is
there a point at which the time/money invested outweigh the benefits one could receive?
This is definitely not to suggest that any of the above methods would not yield results. It
18
is very possible that a traveling salesman approximation could be adapted to provide a
good estimate for the SBV problem. The key is that none of the above problems have a
clear parallel with the SBV, and thus would require a good deal of work for possibly little
benefit. Is there another alternative to finding a working deterministic algorithm?
As suggested by Prof. Kaelbling, the answer is yes. It is no surprise that such an
approach comes from the A.I. field, where generally the amount of input available to
machines and the choices that have to be made place the search space well into the realm
of NP-complete problems. However, for those who have not worked with these problems
before, the resulting change in paradigm is quite striking. One can then think of
"solving" a problem not solely as finding the algorithm that gives an approximate answer,
but instead as Figure 3 suggests, using such an algorithm to find a starting point and
iterating toward a better solution. This approach is also beneficial in that one could use a
variety of deterministic algorithms, iteratively improve them, and take the best result. Or,
as some iterative improvement algorithms such as genetic algorithms suggest, one can
take the results of more than one deterministic algorithm and attempt to combine them to
provide a new, improved result. It is allowing this option that might provide a great deal
of improvement to average results.
Predicting Satellite Locations
To determine if this new approach was applicable to the SBV scheduling problem, the
next step was to construct a software model of the system currently in use by MIT
Lincoln Laboratory. The first requirement was that one needed to be able to determine
where the satellites are at any given point in time. The actual software/computational
19
Figure 3: New Paradigm for Path Development
K
POSITIONAL DATA
Information about orbits received from
previous radar and satellite measurements.
I
ORBIT ALGORITHM
Apply deterministic algorithms to find
candidate paths for the SBV satellite. Ex:
Local maximum of F(X) [see box 3]
Local maximum: A1 1A2A 33A 5 A 45 A 34A 8 8A 44A 65 ...
Distance heuristic: A 45 A 65A 3A 34A 22A 9A 7 7A55 A 65 ...
Other heuristics: AIA2 A3A 34A 10A1 1A 8A 444A 664 ...
F
EVALUATE PATH: F(X)
Apply a function that maps the path of observations to
a numerical weight or value of the path; based on the
number of satellites viewed, importance of individual
satellites, etc.
RANDOMIZED IMPROVEMENT
Apply randomization to improve the candidate path.
Includes straight randomization and simulated
annealing (Russell, 113).
IF
GENETIC ALGORITHM
2
2I
Input paths from in a "Darwinian-style" algorithm. Includes:
assigning a probability G(X) = F(X)path/Z(F(X)paths), replicating
paths based on G(X), combining and mutating the result.
FINAL PATH
20
resources that are used for the scheduling of the SBV would be far more exact in terms of
accuracy of the satellite positions, etc. However, as far as testing the greedy algorithm
and the effectiveness of randomized improvement, a simple model of elliptical orbit
propagation would give the same kinds of constraints on the SBV (time windows,
variable satellites in field of view, etc.), without utilizing expensive computational
resources. The elliptical model was thus used as a measure on how the randomized
improvement might increase the SBV's performance.
The process of determining the satellite position can be broken down into 2 distinct
stages according to function:
1.
Stage 1: Checking Loading the Element Sets of the Target Satellites
2. Stage 2: Propagating the Satellite Orbits
Stage 1: Checkinig/Loading the Element Sets of the Tar2et Satellites
Definition of an Element Set
In order to examine the problem of determining the best flight path for the SBV, we
are going to need to know where the SBV and the target satellites are at any given time.
To do so, we make use of a database at MIT Lincoln Laboratory that contains
information about each of the various satellite orbits. This database maintains
information on the satellites in the form of an element set: (EX, 0, i, Q, e, o>, M, a, D, Y,
S), as shown in Figure 4, where:
21
EX: format of catalogue
0: object number
i: inclination of the orbit plane
Q: right ascension of the ascending node
e: eccentricity of the orbit
(o: argument of perigee
M: mean anomaly of the orbit
a: semi-major axis of the elliptical orbit
D: day number in date of epoch
Y: year number in date of epoch
S: source of information
Figure 4: Sample of Element Set Catalogue
EX 00005
EX 00006
EX 00008
EX 00011
EX 00012
EX 00016
EX 00020
EX 00022
34.247
51.673
51.608
32.889
32.893
34.258
33.344
50.297
211.266
103.837
60.824
296.069
131.834
141.399
21.917
64.330
0.185883
0.001649
0.001700
0.151284
0.170641
0.204027
0.172616
0.022280
200.867
293.431
48.928
329.824
155.663
35.366
78.152
234.994
150.506
81.714
311.577
22.303
213.514
336.655
300.668
122.990
1.3539966
1.0539522
1.0596448
1.2813512
1.3115174
1.3846119
1.3058183
1.1061608
354.8648120
35.3000000
70.8697858
355.2196380
355.7872150
354.8629760
354.1773870
352.5593620
99 SPD
95 LRO
91 TOS
99 SPD
99 SPD
99 SPD
99 SPD
99 SPD
Now, this might look intimidating at first sight, but the numbers represent very simple
concepts in determining the position of a satellite at a given time. First, we have to find
where the satellite is in its particular orbit. We know that the orbit is in the shape of an
ellipse, as shown in Figure 5.
Looking at this figure, we also notice that a is the length from the origin to
apofocus/perifocus, and is also the semi-major axis (given in element set). Further, by
the properties of an ellipse, the sum of the distance from any point K on an ellipse to one
of the foci and the distance from K to the other foci is always 2a. Thus, if we consider
the point in the orbit where the satellite is a distance b from the origin and equidistant
from the foci, we have a triangle as shown in Figure 6:
22
Figure 5: Model of the Elliptical Orbit (Berthoud)
Auxiliary circle
r
Apofocus
E
Impty' focus
Perifocus
E
F oc u
P
Li n\e of
apsides
b
e=O.8
-a
ae
-r'PJ
r'
I I
Figure 6: Satellite at point equidistant from foci
a
Focus
1
ba
ae
ae
Focus 2
Now, we can see by Pythagoras that b = [(a 2 - (ae) 2)f . Thus, the quantities a and e
completely specify the shape of the elliptical orbit of the satellite. However, the ellipse is
23
only a 2-dimensional object. Therefore, the next group of numbers in the element set
specify how the ellipse in oriented in space relative to the Earth, as shown in Figure 7.
First, we need to determine a coordinate system with which to reference the various
satellite orbits. To do so, we start with the origin equal to the center of the earth, which
will also serve as a focus for each of the elliptical orbits. Then, we determine the x-axis
as going toward the star of Aries, which is also the point at which the Sun is located at the
vernal equinox. This is so that we have, to a good approximation, an inertial reference
system, i.e. one that is unaffected by the movement of the Earth about the Sun. The zaxis is then defined from the center of the Earth through the North Pole (ignoring
movement of the Earth's axis of rotation). Finally, the y-axis is defined so that we have a
right-handed coordinate system (i.e. the cross product of unit vectors along the x and y
axis is equal to a unit vector along the z axis).
Figure 7: Model of the Orbital Plane with Respect to Earth (Levine)
North
desc:enc-ng rode
43
Ewgee
--
plane
/
-~
line of
Vernal
u2.ifox
24
Once we have this coordinate system in place, the elements Q, (o, and i can be
explained. The ascending node is the point in space where the satellite crosses the x-y
plane moving from -z to positive z. The "right ascension of the ascending node" Q
represents the angle between the vernal equinox and this ascending node in the x,y plane,
which represents a measure of how far the orbit is twisted about the z-axis from a
common reference.
Next, the argument of perigee o specifies at which point in the orbit the satellite
reaches the point closest to the earth. This is again an angle referenced to the ascending
node, and specifies the orientation of the ellipse within the orbital plane.
Finally, the inclination i represents the angle between the x-y plane and the orbital
plane (not shown in figure). This is due to the fact that with the values of Q and o, one
can still imagine rotating the elliptical orbit about the line of nodes, while the inclination
specifies the exact orientation. Thus, with these 5 elements: Q, O, i, a, and e, we can
completely specify the shape of the elliptical orbit in space.
Once the position of the elliptical orbit has been determined, the mean anomaly M
and the time of epoch (D and Y) are used to determine the position of the satellite within
the elliptical orbit. This will be further examined in the section on propagating the
satellites in their orbits.
Finally, there are 3 entries in the element set which are not used for the orbit shape or
the satellite position. EX represents the format of the catalogue, so that users know
which element is in which position. Once again, this element set format is given as: (EX,
0, i, Q, e, (o, M, a, D, Y, S). The object number "0"is simply a unique identifier that is
assigned to each of the satellites and other orbital objects so that one knows which object
25
is being tracked. The source "S" is simply a reference that denotes which method was
used to take the measurements of the satellite.
Method for Checking/Loading Element Sets
First, the element sets are given as a text file with all of the varying element sets
contained on a different row. The model that we use is developed in MATLAB, which
has a function that will read in a text file and place the entries into a matrix of values.
This matrix only recognizes number entries, however, all that is lost is the format type
and the code for the source of the element set, and these are not important entries for the
model.
What we are then presented with is a matrix that contains the element set for every
(unclassified) object that is tracked in space. However, not all of the element sets in the
catalogue represent objects that are tracked by the SBV satellite. Some might have orbits
that are too large to constantly be monitored by a low-orbit satellite such as the SBV.
Others might be currently unobservable, as the most recent measurements of the target
satellite orbits are so old as to make accurately predicting a future location of the satellite
virtually impossible with the given data. Thus, we need to decide which element sets are
valid, and which are to be ignored. We do this by simply running through the original
matrix with the following criteria: the semi-major axis a must be between 3 and 25 earth
radii, the eccentricity must be less than .9, and the date of epoch must be sooner than
Dec. 26 th, 1998. Any element set that meets these restrictions is then placed in a new
matrix which will be used as the complete list of all possible targets for the SBV satellite.
When this approach is run on the unclassified catalogue, we find that only 1291 satellites,
26
or 12.73% of the entire catalogue, are valid targets. Thus, we have a significant number
to consider, but also a significant reduction in the total number of possible targets.
Stage 2: Propagating a Satellite Orbit
Finding the Mean Anomaly
We have already seen that the element set completely specifies the orbit of the
satellite around the earth. However, we have not explored how the position in that orbit
is given by the values contained in the element set.
First, N is defined as the mean velocity of the satellite, and can be obtained in the
following manner. The period P of the orbit is defined as 211(a 3/2 /u1 / 2 ), with "a" being the
length of the semi-major axis as defined above. Further, "u" is defined as the product
G(mi + m2 ), where G is the constant of gravitation and mi, m2 are the masses of the
individual objects (earth and satellite). The mean velocity N is then simply 2H/P, or
u
/
a-3.
Noting that the mass of the satellite will be inconsequential compared to the
mass of the Earth gives the following simplified equation: N = (GMearth) 1/ 2 a-3/2, thus, the
mean velocity is simply a function of constants and the size of the elliptical orbit.
Now, we define the position of the satellite relative to the time at which it passes
through the argument of perigee (occurring at the epoch T). Thus, as M1 = N(t] - T) at
one moment in time, and M2 = N(t 2 - T) at another, then M2 - M= N(t 2
-
tI) -> M2= M1
+ N(t 2 - t1 ). The element set gives a mean anomaly M1 , and a corresponding time = D,Y.
Thus, we can simply calculate M2 as a function of the time at which we would like the
measurement. Once we find M2 for a given time, then using Kepler's
2 nd
law, we find
27
that the eccentric anomaly E of the elliptical orbit is given by M2 = E - e(sinE). The
eccentric anomaly is defined as the angle between the x-axis and the projection of the
satellite onto the circle with radius equal to the ellipse's semi-major axis. (E is shown in
Figure 5). Once we have the eccentric anomaly, we can find the true anomaly, or angle
from the x-axis to the satellite's true position. However, solving Kepler's equation for E
requires using various methods of successive approximation, but once done the position
of the satellite in the elliptical plane can be specified at any point in time.
Newton's Method for Kepler's Equation
As previously demonstrated, we can get the value of the mean anomaly M2 at some
point in time from the mean anomaly MI given in the element set. Then, to find the
eccentric anomaly E, we need to solve M2 = E -e(sinE). Since a closed form expression
is not possible, we use Newton's method to find the value of E. The first step in this
method is giving a guess to the value of E, call this value E0 . We then notice that we are
really trying to find the root of a one-variable equation: f(E) = E - e(sinE)
-
M2 , since M2
is a given constant. Newton's method states that to iteratively find the root of a singlevariable equation, we use the following formula:XXn 1= Xn - f(Xn)/ f' (Xv). Thus, each
successive approximation to the root of the equation is found by using the slope of the
function at the point of our last guess, and finding where the tangent line intersects the xaxis. We continue until either the relative iteration error =
- X, I/ JX II or the
absolute error lf(Xn)I, is less than a given threshold.
The first method of error measurement signifies that the two iterations are
significantly close together to approximate f(X) = 0, while the second method simply
28
measures the actual value of f(X). The two approaches are fairly equivalent, although the
relative error approach requires a much higher threshold to avoid problems. If we
compare the two approaches with a threshold equal to .001, we see in Figure 8 that after a
large number of cycles (the eccentric angle has cycles of 21I) the relative error
requirement gives an erroneous result when compared with the correct graph given by the
absolute error.
Figure 8: Comparison of Relative Error vs. Absolute Error
Abs. Eror
wth
.001
tlreshold
Rel. Error
2
wth
001 threshold
2
18
1.8
1.6
6.6
14
11
14
1.2
01
~086
018
,
0.6
0.4
0.4
0.2
0.2
167
167.5
166
Cycle
1640
b
41 eliptical orit
169
169.5
170
167
167.5
168
Cyso
166.5
f e41
pica o41
Nt
169.5
169
170
As we can see in the above graphs, there is substantial erratic behavior if we use the
.001 tolerance with the relative error measurement. If this tolerance is increased to
.000000 1, this problem is resolved, and the running time of the algorithm is comparable.
Thus, whichever method of error analysis is used will give the same results, but one must
be sure to find an appropriate tolerance for the type of error being measured.
The next concern with Newton's method is that the iterations are performed by
dividing f(Xn) by f'(Xn). Obviously, if f'(Xn)= 0, the approximations go to infinity and
the process diverges. We are lucky, however, in that for this case f' (Xn)
=
1- e(cosE),
which only equals 0 if cos E = 1 and e = 1. However, during the process of loading the
29
element sets we constrain all applicable element sets to have an eccentricity less than .9,
so we do not have to worry about dividing by 0.
Finally, we do have the unfortunate side effect that the iterations sometimes enter into
infinite loops. This occurs when the approximations do not make advancement toward
the root, but end up giving an approximation that was already attempted. Since the
iterations are deterministic, the process will continue in a loop without converging or
diverging. The only solution is to attempt a new guess for the eccentric anomaly E. The
cycle is noticed as the model will only allow 50 iterations before halting the process and
trying a new starting point. After the first round, the starting point is adjusted by
subtracting 1 radian from the final guess of the previous rounds final approximation. If a
cycle is entered again, then after another 50 iterations a new value is chosen equal to the
last attempted value in the failed iteration + .75 radians. If this fails a third time, we
simply start at 0 radians and increment the guess by .4 radians until a solution is found.
Experimentation found that over 99% of the time the eccentric anomaly is found in the
first attempt, with no cycles. Subtracting 1 radian solves 99% of the cases for which this
fails, and adding .75 radians handles 99% of the cases that reach this stage. Only a few
times is the final round necessary, and it has not yet failed. Newton's method is
guaranteed to converge if the initial guess is within a certain range of the actual result,
and thus far this has shown to be the case.
30
Eccentric Anomaly to (x,y,z) position
Once we have the eccentric angle E of the satellite, we can find the xw and yw
rectangular coordinates of the satellite (in the elliptical plane) by the following relations:
xw
= a(cosE - e) and yw = a[(1 -e2)]1 2 sinE. In order to test the model thus far, we
propagate the element sets of a few satellites over a complete orbit, with the results
shown in Figure 9 below:
Figure 9: Samples of Elliptical Orbit in 2-Dimensions
X10,
Sample of first 30 element set orbits
4/
x0S
We can see that the orbits do indeed form ellipses around the earth (shown as a gray
circle in the figure with radius equal to the average radius of the earth), as we would
expect. Thus, we can conclude that the orbit propagation is working accordingly.
Then, we project the rectangular coordinates of the satellite in the elliptical plane into
the non-inertial reference frame, once again defined by the center of the earth as the
origin, with the x-axis pointed toward Aries, the z-axis through the earth's axis of
31
ME
rotation, and the y-axis defined so as to give a right-handed coordinate system. The
transformation (Roy, 103) is given as follows:
1)
2)
x = xWPx +yWQX
y = xPy +yWQy
3)
z = xwPz+ ywQz
4)
5)
6)
7)
8)
9)
Px= cos o cos Q - sin o sin Q cos i
Py= cos o sin Q + sin o cos Q cos i
Pz= sin o sin i
Qx= -sin o cos Q - cos o sin 0 cos i
Qy= - sin o sin Q + cos o cos 0 cos i
Qz= cos o sin i
Once again we propagate some sample orbits to check the validity of our approach, as
shown in Figure 10. We can see that this method does indeed give the type of orbits one
would expect. The SBV orbit is also shown, though difficult to see as it is a low-altitude
orbit (shown as a small, near-vertical ellipse, tilted slightly toward the right).
Figure 10: Three-Dimensional Orbits of Target Satellites (all axis in km.)
Sample of various orbits, SBV and Earth included
x 10
2,
1
-2
-3,
-4-5
-5
X 10,
00
x
10
X 10'
-5
-5
Now, we can use the element set of a satellite to accurately determine a (x,y,z)
position for the target satellite at any point in time. We can therefore determine a vector
32
from the center of the earth to any satellite that we choose, at any time that we choose,
given the element set. If we also find the vector to the SBV at the same time, we can use
the difference of those vectors to gain a SBV to Target Satellite vector. This new vector
represents the direction we would like to point the CCD's to observe the target satellite.
Planning the SBV Observation Path
Now that we are able to determine the direction that the SBV should point to observe
a target satellite at a given time, we need to determine how we are going to decide which
schedule of orientations will give the best result. As the greedy algorithm is the one
being modeled, we need to simply decide at each point in time which SBV orientation is
optimal as far as figure of merit, choose that orientation, and continue. However, there
are a number of issues to consider:
1.
There are a variety of different ways to model the iteration process.
2. How does one eliminate unobservable satellites (due to sun/earth)?
3. How does one determine a figure of merit?
Modelin2 the iteration process
At this point, a significant amount of information is available for our use. In addition
to having the position of the satellites we have, from observational heuristics, the amount
of time required to transition from one SBV orientation to another. There are then
different factors that need to be considered, such as how one increments time (discretized
33
time steps or modeled travel time?) and how to determine the orientations that will be
considered. This leads to a variety of possible models for scheduling the SBV flight:
1.
Field of View Modeling
2. Target Satellite Modeling
3. Path-Satellite Modeling
Field of view modeling (Dr. Ramaswamy Sridharan)
Discretized time, discretized space
We could model space as a collection of various non-overlapping fields of view.
Then, we could figure out which satellites would be in a particular field of view, and
simply find the SBV path that would maximize the count of satellites at each particular
time. For example, consider the array below:
Table 3: Sample for field-of-view modeling
Time:
0
T
2T
3T
4T
Fieldi:
3 sat.
5 sat.
0 sat.
0 sat.
3 sat.
Field2:
1 sat.
0 sat.
0 sat.
0 sat.
1 sat.
Field3:
12 sat.
0 sat.
1 sat.
0 sat.
1 sat.
Etc...
where the indices on the y-axis are the non-overlapping visible fields that span the
possible legal views of the satellite, and the x-axis indicates the current time (in
increments of T). Now, one could use this approach to model the greedy algorithm by
34
simply picking the highest value at each time for the resulting field of view of the SBV.
However, some problems emerge. First, it is highly probable that the overall globally
maximized path does not use fields of view that correspond to our model of the fields of
view, and thus the greedy algorithm will be less accurate also. Second, the issue of
which discretization value T to use is important. The travel time between fields can
range between 1 to 3 minutes, so we consider the following two cases:
1.
Large discretization value T: When a path is being considered, it is likely that the
amount of travel time from the current array entry will not land on another discrete
value. If we then model the path based on the next possible discretization value, we
might end up wasting a lot of otherwise valuable time, reducing the effectiveness of
our results.
2. Small discretization value: Solves the problem of effectiveness, as the amount of
unused time is decreased, but the size of the array has thus increased. This becomes
important when one considers the computation time involved with finding a solution.
Thus, the difficulties become deciding the size of the array, and finding optimality
based on the speed of calculation vs. error.
Target-Satellite Modeling
Discretized time, continuous space
This model comes from the realization that at any given point in time, the optimal
SBV path will either have the SBV viewing a target satellite and gaining information on
it, or in transition to view a target satellite. Thus, we could use the approach that instead
35
of considering a pre-determined field of view, one could make the assertion that every
field of view must have the first CCD of the SBV containing a target satellite. Then we
have defined a point in the field of view. However, we have not yet completely specified
the orientation, as the rectangular field of view is free to rotate about the center we have
just established (Figure 11).
<
Figure 11: Different Alignments of SBV Field of View on One Target Satellite
To completely specify the orientation of the SBV, we then require that the second
CCD must have a target satellite in its field of view, if possible. In this way, we have
defined a line in space, and thus a field of view for the SBV. If no target satellite is
available in the second CCD at that time (for any rotation) then we use the third, then the
fourth. If none of these CCD's will have a target satellite in view at the appropriate time,
then we can pick the orientation that minimizes the flight time of the SBV as a general
approximation.
Once we establish this method, we again model the problem as an array, except
now we focus the y-axis on the target satellites (Table 4). The array entries are then a
function of the figure of merit, with a new entry n.a. signifying that a given
36
Table 4: Sample for target-satellite modeling
Time:
0
T
2T
3T
4T
Target12:
Target13:
Etc...
40
12
20
23
10
30
3
23
100
32
Target21:
Target23:
Etc...
1
38
n.a
83
n.a.
92
n.a.
92
n.a.
91
satellite is not viewable at a particular time. This again suffers from the problem of
discretization times, with the trade-off being the same as in the approach discussed
earlier. This model can also be used for a greedy algorithm, with the final path being
chosen by whichever orientation maximizes the function at each time.
Further modifications can also be made to this model at the cost of complexity.
Technically, the target satellites should be in the field of view for a certain time range to
allow for observation. Also, the CCD's read from CCD1 to CCD4 at different times, and
not all at same time. However, to control the size of the model, we assume that any
satellite that is in the field of view is viewable at any instant within the time for all 4
CCD's to capture data.
Path-Satellite Modeling:
continuous time, continuous space
The final modeling approach is a solution to the discretization constraints that were
presented in the first two models. The fact that the path that the SBV takes will not easily
37
conform to a discretization of time suggests that an effective model incorporate the paths
as a sequence of events instead of a sequence of times. The new approach simply
examines a set of possible paths on the y-axis, while using the x-axis to examine the
possible sequence of events, along with a counter to indicate when the path has run out of
time (Table 5).
Event
Table 5: Sample for path-satellite modeling
2
1
0
Path1:
sat4,1 (3 min)
sat2,3 (10 min)
Path2:
sat6,5 (7 min)
satl,76 (12 min) sat32(14min) satl2,36 (21 min)
Path3:
sat8,65 (2 min) sat52,34 (9 min) sat53(19min) sat63,97 (26 min)
3
sat3,9(15min) sat10,12 (35 min)
Etc...
In this manner, we still run into the problem of a large number of orientations to
examine, as in target-satellite modeling, but we have solved the problem of the timing
constraint that was placed by discretizing the time steps. We then run the greedy
algorithm by finding the orientation that maximizes the figure of merit at each event.
For the analysis of the greedy algorithm and the randomized improvement, it is this
path-satellite model that was chosen. This method is the most accurate in following the
approach of the greedy algorithm (Table 1), mainly due to the inability of the other
approaches to handle the large variance in the time for transition between SBV
orientations. There is only one real difference between the model of the greedy algorithm
and the actual algorithm. This is that the greedy algorithm would schedule the flight of
the SBV by considering the positions of the satellites at the time when the SBV would be
38
viewing those satellites. This is not computationally possible with the model, as one
would have to compute the locations of all satellites at all points in time. However, we
can approximate the time of each event by considering the time of the last event and
adding on the average transitional orientation time (2 minutes). Then, we compute all of
the satellite positions at that time, and use that for a comparison, betting that the real
position will not deviate too much from this approximate position. However, the key
difference between this model and the others is that when an orientation is chosen, the
real transition time is added to find the time of the event. Thus, time is not evenly
discretized, as it was in the other models.
Conclusion
While all of the models have strengths and weaknesses, for the purposes of
comparison in this paper we chose to use the path-satellite model. The time
discretization of the other models would turn the problem into a static matrix of constant
size, which could possibly be approximated with one of the algorithms for prizecollecting traveling salesman, as previously discussed (though the resulting graph would
have over 1,000,000,000 nodes!). However, for consideration of the greedy algorithm
with iterated improvement, the non-discretized time approach is attempted.
Determining Valid Satellite Targets
Now that we have a way of determining where the SBV can point, and a framework
model for simulation of the SBV path, we can consider how to determine which satellites
are target candidates at each event. We know that all of the entries in our matrix of
39
element sets are candidates at some point in time, but we do not currently know if the
earth or the sun is interfering with our observation of each satellite at the current time.
Earth Constraint
At each point in time, the SBV is not going to be able to look at some of the target
satellites due to the fact that they are either hidden by the earth or have the earth as a
backdrop. In order to determine if this is the case, we use the fact that we know the point
that the SBV is at relative to the center of the earth. We also know the coordinates of the
target satellite at the same point in time. Taking the difference of 1) the vector from the
center of the earth to the SBV satellite and 2) the vector from the center of the earth to the
target satellite gives the SBV-Target vector as earlier discussed. Further, since we have
the points at which the SBV and Target are located, we can find the length of the two
vectors above and the distance between the SBV and Target simply by using the
Pythagorean Theorem in 3-dimensions, which yields that the distance between two points
(xo,yo,zo) and (xi,yi,zi) is equal to ((x1-xo) 2 + (yi-yo) 2 + (zI-zo) 2) 5 . Now, Figure 12 shows
a cross-section of the earth in the plane formed by the earth-SBV and earth-Target
vectors.
Since we have the values for the length of each of the sides of the triangle formed by
the center of the earth, SBV, and target satellite, we can use the Law of Cosines to find
the angle A. This law states that if 2 sides of a triangle (a and b) and the angle m between
them are known, then the third side c is given as c2 = a2 + b2 -2abcos(m). Rearranging
this equation for the case when the 3 sides are known, but not the angle, gives that the
40
angle A
=
acos[(ES 2 +ST 2 -ET 2 ) / (2(ES)(ST)] (with ES
=
Earth to SBV distance, ST
=
SBV to Target distance, ET = Earth to Target distance).
Figure 12: Model of Earth Constraint
Target
s
Earth to Target
T
R
A
Origin
Earth to SBV
'SBV
Now, we know the threshold at which the angle A is too small as follows: the earth's
radius R is given to be approximately 63,781,400 meters. As we can see from Figure 12,
if the Target is just at the threshold, then the SBV-Target vector is tangent to the circle
with radius = earth's radius. Further, we know from geometry that any line tangent to a
circle is perpendicular to the radius drawn to the point of tangency. Thus, we have a right
triangle, and the threshold angle is simply equal to asin[R/(ES)] (Note that we need R <
ES to get a real value for the threshold, but this is met as long as the SBV is in orbit).
Therefore, the way that the constraint of the earth is checked is that each distance
(ES,ET,ST) is calculated, and then the law of cosines gives the ES-ST angle. We
compare the resulting angle with the threshold found as previously noted, and if the ES-
41
ST angle is greater than the threshold, the satellite is viewable from the SBV with respect
to the earth constraint.
Sun Constraint
The constraint due to the sun is handled in much the same way that the constraint due
to the earth was calculated. The SBV is not able to view objects within 80 degrees of the
vector from the SBV to the sun, so we already have a threshold angle A. As long as the
angle between the Sun to SBV vector (SnSbv) and SBV to Target Vector (SbvT) is
greater than 80 degrees, the Target satellite is viewable.
The difficulty lies in finding the position of the sun, due to the fact that we do not
have an element set for the sun's orbit. The main reason for this is that the sun
technically does not have an orbit, the earth moves around the sun. Luckily enough, the
earths orbit about the sun has a very low eccentricity (about .0167) (Roy. 513), so we can
make the simplifying assumption that the earth has a circular orbit around the sun. If this
is allowed, then the sun will appear to orbit around the earth in a circle (we have a
constant distance separating the two). We know that the earth orbits the sun in 365.24
days (Roy. 508) and that the mean distance from the sun to the earth is 149,500,000 km.
This leads us to the orbit shown in Figure 13:
Figure 13: Planar Model of Earth's Orbit Around Sun
arth
R
1W
PP-Vernal
Equinox (3/20/2000)
42
We also know that the vernal equinox occurs approximately on 3/20/2000. Thus,
given the time at which we want the position of the earth in this circular orbit, we simply
find the arc length as (new date - vernal equinox date)/365.24 days. Then, arc
length/(2*pi*r) = 0/(2*pi), or 0 = arc length/r. We can thus find the angle that the earth
is off of the vernal equinox given the time of interest.
Now, the next issue is that the sun's apparent orbit about the earth will be inclined to
the x-y axis of the celestial coordinate system described earlier. However, we know that
the vernal equinox coincides with the First Point of Aries, and the earth's orbital plane is
given to have a 23.439 degree inclination to the equatorial plane. Thus, we can model the
sun's "orbit" around the earth as shown in Figure 13. Then, as we see in Figure 13, we
can use this position in the orbital plane to determine the (x,y,z) position in the celestial
coordinate system. We do this as follows:
1.
We are given R = 149,500,000 km., i = 23.439 degrees, and 0.
2. From Triangle 1, W = R*(sin 0), x coor. = R*(cos 0).
3. From Triangle 2, y coor. = W*(cos i)= R* (sin 0)*(cos i), and
z coor. = W *(sin i) = R* (sin 0)*(sin i).
Then, once we have the (x,y,z) coordinates of the sun relative to the celestial
coordinate system, we can solve for the angle between the sbv-target and sun-sbv in the
same manner as the earth constraint, and compare the result to the threshold of 80
degrees. If the angle is greater than 80 degrees, the sun does not hinder the observation
of this particular target satellite.
43
Specifying SBV Orientation
We are now at the point where we have a matrix of the element sets for only the
viewable satellites at the current point in time. According to our model, we would now
like to consider all of the possible satellite orientations defined by pointing the CCD's at
each possible target, and then defining the orientation by another satellite in the field of
view, as shown in Figure 14.
Figure 14: Possible Orientations to Consider for SBV
Different Orientations
0
Primary vector
SBV
The primary vector represents the vector from the SBV to the primary target, around
which the field of view is free to rotate. For our simulation, all of the possible targets are
considered as potential primary targets. We then determine which satellites will fit in a
field of view with the primary target, and thus the possible orientations are defined. If no
satellites are available to define an orientation, then orientations can be generated at
random intervals around the primary target. However, it can be a simplifying assumption
that the globally optimal path would always look at 2 satellites as a minimum, though this
is not necessarily always the case.
44
Now, how does one determine which satellites are within the field of view of a given
principal target? Since we have all of the vectors from the SBV to the target satellites,
we simply determine the angle between the SBV-principal target vector and the SBVsecondary target vectors. This is done simply by calculating the length of each of the
vectors (including the primary target- secondary target vector) and applying the law of
cosines as was done in the analysis of the sun constraint. Further, we know that the SBV
CCD's only have a field of view of 1.4 by 1.4 degrees each, so the total field of view is
1.4 by 5.6 degrees. Thus, we immediately eliminate from consideration all secondary
targets that are more than 5.6 degrees away from the primary target. What we can then
do is project each of these satellites into the plane perpendicular to the primary vector and
including the primary target.
Figure 15: Projecting Satellites into Perpendicular Plane
Secondary Target
S
Primary Target
r
SBV
We already know the distance from the SBV to the 2 targets, and the angle between
the SBV-Primary and SBV-Secondary targets. Then, as seen in Figure 15, we can find
45
the distance from the SBV to the projection of the Secondary Target to the plane
perpendicular to the Primary Target (denoted s) as s = r/cos(O). Then, since we have the
vector from the SBV to the Secondary Target, we simply scale that vector by s/m, where
m is the length of the SBV-Secondary Target vector.
Once we have all of the possible secondary targets projected to the plane, what we
really have is a circle containing the projection of any satellite that can be viewed at the
same time as the target satellite. However, the SBV orientations are not simply equal to
the lines connecting primary to each secondary target. Further, we must know how many
satellites are in each field of view, and also meet a constraint based on the position of the
sun once again.
First, we need to define the potential SBV orientations. Given the circle containing
the projections of the secondary satellites, we arbitrarily choose one of the secondary
satellites as a base (call this the reference secondary satellite), and define the z-axis of a
new coordinate system as going from principal target to secondary target. The y-axis is
defined as perpendicular to this z-axis, in the plane of the satellite projections. The x-axis
is along the SBV-principal target vector.
Now, each satellite projection can be referred to by an angle of rotation off the z-axis
in the plane. This angle can be simply found by finding the distances between the
principal target and the reference secondary target, the principal target and the secondary
target under consideration, and the distance between the secondary target and the
reference secondary target. Given these distances, we have a triangle with the lengths of
all three sides known, so we use the law of cosines again.
46
Now, for simplicity in the model, we will assume that the field of view is a wedge
instead of a rectangle. This assumption does not generally change any of the major
aspects of this problem, and will be applied to both the greedy algorithm and the iterated
improvement. What this does allow is that any two secondary satellite projections that
have angles of rotation within 1.4 degrees of each other can be considered in the same
field of view. Thus, we can simply sort the secondary satellites by angle of rotation. We
then use each secondary satellite as a base and find all of the satellites within 1.4 degrees
clockwise of the base. If a secondary satellite is within 1.4 degrees counterclockwise,
then the orientation will be found when considering that other satellite as a base. Once
we have all of the satellites that are within 1.4 degrees of the base, an orientation is
defined by averaging the rotation angle of the base with the largest rotation angle of a
satellite within the 1.4 degrees of the base to find the midpoint angle of the candidate
orientation, thus increasing the likelihood that the satellites will stay in the field of view
during the observation process. Note that if no other satellite is in the field of view with a
given target satellite, then the angle of rotation of the sole secondary target is used as the
midpoint angle of the field of view to be considered, shown in Figure 16.
Once this is done, we have a count on how many satellites are within each potential
field of view, and we have a rotation angle for the midpoint of each of the orientations.
We then define the SBV orientation in a new coordinate system: a unit vector from the
SBV through the center of the 3 rd CCD (denoted slant range vector) defines the x-axis of
a new coordinate system. A unit vector from the center of the
of the
4 th
3 rd
CCD through the center
CCD is along the new z-axis, and the y-axis is defined accordingly to make a
right-handed coordinate system.
47
Figure 16: Different Orientations of the SBV
Plane of projected satellites
Orientation after averaging
One satellite, no averaging
x
X
x
x
x
X
x
In order to take our proposed orientation and give the position in terms of the new
coordinate system, we simply have to use the angle of rotation ((D) that we earlier
calculated. We use this to calculate the unit vector from the principal target along the
angle of rotation, and this along our new z-axis. The y-axis is found by incrementing the
angle of rotation by 90 degrees. This procedure is shown in Figure 17. Note that zold,
y_old represent unit-vectors along those axis. We then calculate the new x-axis by sliding
the SBV-primary target vector 3.5 degrees along the new z-axis (1.4 degrees per CCD,
need to travel 2.5 CCD's to reach the center of CCD 3). The orientation is then defined
by unit vectors in the x,y, and z directions.
Now, once we have the vectors for the proposed orientation, we do have to check one
final constraint. The unit vector along the new positive y-axis should point away from
the Sun. We have the position of the sun, and we have the unit vector along the y-axis, so
we simply calculate the angle between the two as we have done for the previous sun
48
Figure 17: Shifting to New Coordinate System
Old y-axis
New y-axis
New z-axis
sin(90-)* Yold
Old z-axis
4
cos(D)*
Zold
cos(90-A)*
-Zold
constraint. If it turns out that this angle is less than 90 degrees, we need to flip the
proposed orientation, so that the negative y-axis is switched with the positive y-axis.
In order to perform this transformation, we simply slide the x-axis to the middle of
the 2
CCD (back 1.4 degrees along z-axis), which will now be the location of the 3 rd
CCD after the orientation is rotated. The unit vectors along the y-axis and z-axis are then
multiplied by -1,
and we have the new orientation as shown in Figure 18.
Through this method, we can now specify the exact orientation of the SBV that we
are considering (x,y,z unit vectors), as well as how many satellites would be contained in
the field of view. Further, we can do this for all possible secondary satellites, given a
primary target. We are then ready to simulate the greedy algorithm.
49
Figure 18: Different Orientations due to Second Sun Constraint
SUN
y-axis
z-axis
z-axis
x-axis
x-axis
y-axis
SUN
Simulation
In order to simulate the greedy algorithm, we first need to decide what parameters
will be used by the figure of merit calculation. For this model, we will determine the
figure of merit by calculating how many satellites are present within a given candidate
field of view, how long the transition to the new orientation will take (if this is not the
first view of the path), and whether or not any of the satellites have previously been
viewed. We can include this last constraint by simply keeping track of the viewed
satellites in a table and incrementing them after each event is chosen. Thus, we have the
figure of merit for each orientation as follows:
Figure of Merit = (#satellites viewable/(Transition Time))
Mk
=
* Xk(1/(Mk)
number of times satellite k was viewed.
50
As specified by the path-satellite model, we calculate the possible orientations based
on the time 2 minutes from the ending time of the previous event. Thus, the simulation
runs as follows:
1.
Event 0: Calculate the orientations at the starting time. Try every viewable
satellite as a primary target, and check all orientations of possible secondary
targets. Find the orientation that maximizes the figure of merit, and record as
the orientation chosen for event 0.
2.
Increment the current time by the 51.2 seconds necessary for actually
observing the satellites, and update the count of which satellites were viewed.
3.
Event 1: Predict where the satellites will be 2 minutes after the new time,
choose the orientation that maximizes the figure of merit, and record as the
event 1 orientation.
4.
Find the new current time by adding the real orientation time plus the 51.2
seconds of observation time to the current time, and update the satellite count.
5.
Find Event 2 by using the same procedure as for Event 1.
6.
Repeat until the current time exceeds the stated finish time.
With this process, we end up with a path that represents the result of the greedy
algorithm approach. The next step is to determine if the incremental improvement
algorithm can significantly increase the resulting path.
51
Results
The first step was to run the greedy algorithm to find a candidate path for the SBV
schedule and find the figure of merit for the result. Once we had this path, we specified
which point to attempt to improve, and then randomly picked a satellite out of the group
of candidate satellites for the SBV orientation at that time. We then optimized the
orientation about that satellite as had been done in the greedy algorithm, finding the
rotation angle that maximized the figure of merit for that particular satellite (see Figure
14). Once this orientation had been found, then we propagated the SBV path for 10
minutes of SBV flight time, using the greedy algorithm, but with the new, randomlychosen orientation as a starting point. Note that the new orientation might be the same as
the original orientation, if that satellite had been randomly chosen out of all of the
candidates. After the 10 minutes of SBV flight time, the new SBV path is concluded by
re-adding the final part of the original SBV path that is still viewable with the current
time. The entire path is then evaluated and the figure of merit compared against that of
the original SBV path. This procedure is shown in Figure 19 below:
Figure 19: Creating new path with randomization
-92
-31
--
11-
Randomly picked satelllite
I1I over 4
4
1
1
-
52
-
141
-
46
133
-
75
-
-11
-18--
12
1
Splice back onto existing path
Propogate new path for 10 "path minutes"
52
Now, assuming that the same satellite was not chosen at random, we have a new
transition time from the previous orientation to the new, randomly-chosen orientation.
We would like to know if this shift in timing is enough to start a new path of
observations, or if the path will simply converge to the original path. Further, would this
randomization yield a better path that the original in terms of figure of merit?
We can see in the model from Figure 19 that in this case, the change in transition time
yielded an entirely new path with completely different orientations. However, when the
trial was actually run, the simulation was not so agreeable.
We randomly picked January 2nd , 12:00 as a starting time for the trial. One note to
make is that due to a programming error, the year of the target satellite's element set was
not factored into the model. Since we check the validity of the element sets with an
epoch cutoff of Dec. 26th 1998, there are some element sets that have the epoch date in
the year 1998 and some in 1999. However, since the model did not use the year, we can
imagine this as all of the dates are assumed to be in 1999. This only affects a few
satellites, however, and does not affect the validity of the results. This is due to the fact
that the orbits used are still valid orbits, just not ones that would currently contain the
target satellite.
Now, using Jan.
2 nd
as our start time, we ran the simulation for 1 hr. of SBV path time
(approx. 3 hrs. of computation time). Then, we attempted to improve the path by 30
randomizations of the
4 th
viewed satellite. What we discovered was that the simulation
did not yield even comparable paths, let alone better paths. Yet another programming
issue with the transition time rendered the exact results unusable for this first trial (later
corrected), but brought interesting considerations to light. First, the resulting figures of
53
merit were not very close to the figure of merit of the original path. Next, there was a
high rate of instances where the new path converged to the original path. If the path
does not have an opportunity to explore new orientations, then one cannot justify not
taking the local maximum given by the greedy algorithm. Finally, the figures of merit
seemed to fall into two distinct regions: both worse than the original figure of merit.
To examine the problem of the relatively low values for the figures of merit, a trial
was run to determine the distribution of satellites in the different orientations of the SBV,
as shown in Table 6:
Table 6: Number of satellites in the candidate orientations at midnight of test days
# Satellites
Day: 2
Day: 130
Day: 260
1
5871
4914
2097
2
632
505
158
3
159
116
41
4
74
16
13
5
37
1
5
6
16
0
1
7
10
0
0
8
3
0
0
9
1
0
0
We see that the randomization step has a very limited chance of getting a satellite that
will lead to an orientation that can view a high number of other satellites. Given this
information, it is not surprising that the figures of merit were not as high. The main point
of the randomization was to allow a small sacrifice at one point to give high benefit in the
future, but with only 10 minutes of simulation, the new path cannot overcome the deficit
of going from nine satellites in the field of view to only one satellite.
The next step was to adjust the model of randomization. Instead of simply picking
the satellites at random, we would simply eliminate any satellite from contention that had
previously been tried. Thus, we would get the original path on the first iteration, then the
path with the next best orientation at the randomization point on the second iteration, etc.
54
When this was applied to the model, we again found the results lacking. The figure of
merit for the original path was 116.9, but we see in Table 7 that the randomized paths
were lacking. Note that Table 7 shows that 10 trials were performed at randomization
points 4 and 9 (i.e. the 4 th satellite in the original SBV path was replaced by the next 9
best, and then the 9th satellite in the original SBV path was replaced by the next 9 best).
Also note that the first trial is not included, as it returns the original path as a check on the
process.
Table 7: Results of iterative improvement on two points in SBV path
Trial:
Point 4:
Point 9:
1
113.9
116.0
2
113.9
110.8
3
113.7
115.8
4
113.5
115.8
5
113.6
115.8
6
113.6
115.8
7
113.6
114.8
8
113.1
116.1
9
116.0
114.4
Unfortunately, we still had not solved the second problem, which was a high degree
of convergence to the original path. This result caused us to examine the original path
more closely to see which satellites were viewed. What we found was that when
calculating the original SBV path with the greedy algorithm, even with keeping track of
the satellites viewed and penalizing repeat viewing, the figure of merit was still highest
when the same orientations were used multiple times. Thus, we needed to change the
figure of merit calculation by deciding at what level we wish to allow repeat views to be
counted, and how heavily we desire new satellites to be observed. We actually kept the
same process for the figure of merit calculation, but adjusted the matrix that keeps track
of how often the satellite has been viewed. Now, instead of incrementing the satellite
count by 1 on each view, we increment by 10. This means that the second time a satellite
is viewed adds (1/11) to the figure of merit instead of (1/2), etc. When the original path
55
was recalculated by the greedy algorithm, the new path did not have any duplicate
satellite views, and thus the iterative algorithm had a more likely chance of showing an
improvement.
The new SBV path (after the figure of merit adjustment) was then subjected to the
iterative process, as shown in Table 8. Note that the figure of merit of the new SBV path
tested was 111.0, and that we are now trading depth of search for more randomization
points, due to the disparity in orientation size depicted by Table 6.
Table 8: Results of iterative improvement on new SBV path
Trial:
Point 5:
Point 6:
Point 7:
Point 8:
Point 9:
Point 10:
1
109.4
104.7
110.0
106.1
105.0
107.0
2
108.9
106.3
110.0
106.0
105.6
104.5
3
111.18
102.7
105.0
106.0
109.6
104.5
4
108.0
105.4
105.4
106.0
109.6
106.4
5
108.3
104.0
107.0
106.1
108.6
105.3
Ave.
109.2
104.6
107.5
106.04
107.7
105.5
We see that we have succeeded in proving that better paths do exist, and that this
method is capable of finding at least modest improvements. We still have not found the
rationale for the disparity between some of the figures of merit, for example why point 6
in Table 8 should yield such dreadful results in comparison with the other points. What
further examination revealed is that this process is highly dependant on the point at which
the new SBV path is appended to the end of the path we are attempting to improve (see
Figure 19). If the final satellite orientation of the new segment is just past one of the
segments in the original path, we might lose one orientation, and waste a lot of time
waiting for the next orientation, as shown in Figure 20.
56
Figure 20: Problem with merging the new oath with the original
-- 92
-31
-
Randomly picked satelllite
4
1
-
_
52
-
46
14
_
13
-75
-11
-18
-
12
Sat. 12 finishes just after 11 needed to
begin, thus we join at sat.18!!!!!
Propogate new path for 10 "path minutes"
Unfortunately, there is not a good way to rejoin the two paths such that this is
completely avoided, due to the time dependence of the model. We could have avoided
the issue altogether by completing the path for each change with the greedy algorithm,
but the computation time became the limiting factor.
The next test was run to determine the effect of position on the iterative improvement
process, and to see if another improved path could be found. Once again, due to the
tradeoff between running time and depth of search, we limit the number of orientations
considered. The results are shown in Table 9 below:
Table 9: Continued tests on SBV path for Jan. 2nd
Trial:
Point 11:
Point 12:
Point 13:
Point 14:
Point 15:
Point 16:
Point 17:
Point 18:
Point 19:
Point 20:
Point 21:
Point 22:
Point 23:
1
108.0
106.6
105.0
102.4
106.1
107.0
107.0
106.0
108.3
109.4
107.0
105.4
110.0
2
104.4
105.0
111.18
110.0
107.0
106.0
110.0
108.3
106.6
107.0
109.4
107.0
110.0
3
104.4
110.0
104.1
102.3
106.1
106.0
110.0
106.0
106.6
107.0
105.4
106.1
111.0
4
105.2
110.0
104.2
101.4
104.2
106.0
110.0
110.0
105.7
108.4
105.4
110.0
111.09
Ave.
105.5
107.9
106.1
104.0
105.9
106.3
109.3
107.6
106.8
108.0
106.8
107.1
110.5
57
Again, we see the effect of the process of splicing on the final point in some cases
such as in point 14. We also find, however, some cases of improved results, as in point
13 and in point 23.
Finally, we attempt to determine if a longer running time after the switch to the new
satellite would yield more significant results. After all, the idea was that the longer the
path ran after the change, the more likely it could overtake the deficit caused by the initial
switch. The results of this test are shown below in Table 10.
Table 10: Iterative Improvement for SBV path - 30 min. continuation time
Trial:
Point 3:
Point 4:
Point 13:
Point 14:
1
106.2
111.0
106.2
104.6
2
107.2
105.9
107.2
110.0
3
105.4
104.5
105.4
104.5
4
107.3
104.5
107.3
103.7
Ave.
106.5
106.5
106.5
105.7
Unfortunately, no improvements were found with the 30 min. search after the switch,
but we do see that the results are very similar to the previous results. However, further
testing would need to be conducted to determine the appropriate tradeoff between length
of the new path vs. benefit gained by the increase in computational demand.
Conclusions
The goal of the project was fairly straightforward. MIT Lincoln Laboratory was
using a greedy, one-step look ahead algorithm to plan the path of the SBV surveillance
satellite. Is this a good method to use, and would another method give a more globally
optimal path? The answer is far more complex than one might expect. The earlier
58
discussion on the different approaches led us to the realm of iterative improvement
algorithms, working with the greedy algorithm instead of replacing it. We have seen that
the iterative approach can indeed yield better results, depending on the metric one uses to
determine the relative value of each satellite. We have also seen that this approach is
highly computationally intensive (averaging 30 minutes of computation time per table
entry in tables 8 and 9, 2.5 hours for entries in table 10) and is not guaranteed to provide
any results.
Thus, is this the final result that should be used? One could conclude that it should
be implemented, simply because MIT Lincoln Laboratory has far greater computational
resources than were used for these results, and this type of solution could easily be
implemented on multiple processors in parallel (each attempted improvement is
independent). However, this is not to suggest that this should be the end of the research
into this area. We have seen that the path's figure of merit is not directly tied into
maximizing the number of satellites at each point on the path, and that the single point
changes can give marginal results. However, a number of questions remain unanswered.
Is there a way to identify segments of the path that are relatively weak and attempt to
isolate those sections of the path for improvement, instead of simply randomly choosing
points? Can we effectively take the many random paths that we find through the one
point improvement, and splice them together effectively with a genetic algorithm
approach? Is there a better way to run the current algorithm, such that the splicing
problem (i.e. losing an orientation opportunity) is reduced? Can we incorporate the
information provided by approximation algorithms to the Traveling Salesman Problem,
etc. to allow us to focus our iterative efforts? There are so many options with this
59
problem that one would have to think this work only scratched the surface of what might
be possible.
60
References
Awerbuch, B., Azar, Y., Blum, A., and Vempala, S., "Improved approximation
guarantees for minimum-weight k-trees and prize-collecting salesmen." Proc. 27th ACM
Symposium on the Theory of Computing: Las Vegas, 1995. SIAM J. on Computing,
28(1) 1999.
Berthoud: http://www.astro.phys.ethz.ch/edu/diploma/berthoud/main.htm
Cormen, T., Leiserson, C., and Rivest, R., Introduction to Algorithms, MIT Press:
Cambridge MA, 1997
Dumas, Y., Desrosiers, J., Gelinas, E., and Solomon, M., "An optimal algorithm for
the traveling salesman problem with time windows," Oper. Res. 48 (1995), 367-371
Harrison, D.C., SBVSystem Definition Document, MIT Lincoln Laboratory Internal
Document, Lexington, MA, 1991.
Levine: http://asd-www.larc.nasa.gov/biomass burn/glossary.html#K
Roy, A.E., OrbitalMotion, Institute of Physics Publishing, Institute of Physics,
London, 1988.
Russell, S. and Norvig, P., Artificial Intelligence, A Modern Approach, Prentice Hall,
New Jersey, 1995.
Solomon, Marius, "Algorithms for vehicle routing and scheduling with time
windows," Oper. Res. 35 (1987), 254-265
61
Appendix 1: Explanation of Code Modules
This section contains an overview of each of the code modules, including
input/output structure of the functions and the other functions that each will call. This
section is listed in alphabetical order by stages.
Stage 1: Checking/Loading the Element Sets
In this stage, the element sets are checked for validity and then brought into
usable form for the simulation.
cat sort.m
input:
output:
calls:
none directly. Needs catl.txt to be available however.
datanew.dat, datalist.dat
-none-
This script checks all of the element sets for such criteria as acceptable orbit semimajor axis (3-25 earth radii), acceptable eccentricity (<.9), and acceptable reliability of
information (is set recent enough, i.e. taken this year?). Datanew is created which has
all of the element set information along with 'ign' spacers to allow for same format as
original catalogue (catl). Dat list is a copy of just the element set information (no
spacers), and good dat is equivalent to datalist except with all elements of one set on
one line. Dat-list and good dat are examples only, not used in any coding.
62
catl.txt
This is a complete list of all element sets to be considered as possible SBV
targets.
dat list.dat
This is a data file of the element sets that were deemed viable by catsort. This
list is not used in code, as it lacks the spacers for correct format. Only used to produce
gooddat for sample purposes.
data new.dat
Equal to dat list.dat except spacers are added to allow for use by readin (format
as the original element set as far as spacing).
format.txt
This file contains the specifications for the format of the element set - used for
reference.
2ood dat.doc
A sample list equivalent to datlist but with all element set on one line for easy
view.
readin.m
input
output:
calls:
file name of a file containing element sets (i.e. datanew.dat or catl.txt)
matrix of element sets for use by MATLAB scripts
-none-
This function simply takes in a file of element sets and puts them directly into
usable form (matrix) for other functions.
63
Stage 2: Prooagating an orbit
In this stage each element set is used to determine where the satellites will be
relative to the celestial plane (coordinate axis determined by 1 s point of Aries, vector
through axis of rotation, and cross-product (right-handed, inertial coordinate system)).
ecc anom.m
element set el and time t (days)
eccentric anomaly of this element set at this particular time
newton
input:
output:
calls:
This function takes the element set and extracts the correct information for the
newton function to find the eccentric anomaly, followed by a call to newton.m.
find p.m
semi-major axis (meters), mean anomaly, and time of anomaly (days).
te = time of perigee for the satellite (days)
mcalc
input:
output:
calls:
M = n*(t-te), so if we know the mean anomaly and the time at which it is taken,
we can calculate n from mcalc, and solve for te = time of perigee.
mcalc.m
a = semi-major axis length (in meters)
n
-none-
input:
output:
calls:
u=
G*(Mearth +
Msat), n = 2*pi/T, T = 2*pi*(a 3 /u) ., solve these to find the value n.
64
newton.m
input:
eccentricity of orbit, time desired, time of epoch, semi-major axis, mean
anomaly
eccentric angle
subfunctions only: temp,deriv,mcalc
output:
calls:
This function takes in the parameters of the element set and returns the eccentric
anomaly of the satellite in its orbit at a time t with respect to a fixed time T. At T, the
mean anomaly is given, as is the semi-major axis and eccentricity of the orbit. The
function uses Newton's method to iteratively solve Kepler's equation for the eccentric
anomaly. The subfunction temp is used for Kepler's equation, deriv is the derivative of
Kepler's equation, and mcalc takes in t,T, and a to produce the adjustment to the mean
anomaly (MI = M2 + n(t-T)). Newton's method is used with an initial guess of 1 rad,
with a tolerance of .000001 and a cycle limit of 50 iterations. If the process times out
(enters a cycle of approximations without improving), a new guess equal to the previous
approximation in the 1st cycle - 1 is attempted. If this fails as well, a guess of 0 is
utilized, with increments of .75 radians per failure. Each round has a 99+% chance of
success on every round it is given.
orbit xy.m
input:
output:
calls:
element set el and time t
position of satellite in orbital plane [x,y]
eccanom
This function takes the element set and time t, finds the eccentric anomaly from
ecc anom, and then converts the eccentric anomaly into a (x,y) coordinate in the orbital
plane, with x and y referenced to the earth instead of the center of the ellipse.
65
period.m
input:
semi-major axis a (earth radii)
output:
single number = length of a period of this satellite (in days)
calls:
-none-
This function returns the length of a period of the satellite with semi-major axis a.
sat vec.m
input:
output:
calls:
element set el and time t
position of satellite [x,y,z]
orbit-xy
This function takes the [x,y] orbit position of the satellite from orbit xy and
converts it to a [x,y,z] position by transforming the orbital plane to the celestial plane.
Equations given by A.E.Roy.
Sta2e 3: Incorporating Constraints (Sun and Earth)
Once we have the ability to determine the [x,y,z] location of any satellite in the
celestial plane, we would like to be able to determine which satellites are potentially
viewable by the SBV at the given time. This is subject to the constraints placed by the
earth and the sun.
earth check.m
input:
output:
calls:
lengths of 3 directional vectors: sbv-earth , sbv-target sat,
earth-target sat
0 if viewable, 1 for not viewable with respect to earth constraint
-none-
66
This function checks the position of the target satellite relative to the earth and the
sbv in order to determine if the sbv-target vector is pointing into the earth. If the earth is
behind the target, an acceptable image is not obtained, and thus this would cause the
target to be removed from possible consideration. Further, if the target is behind the
earth, an image is obviously not obtainable.
sat avail.m
input:
output:
current time, matrix of element sets, # of satellites to use from matrix
matrix of available targets, each row = [target#, xpos, ypos, zpos]
referenced to current time
satvec, vec length, earthcheck, sun vec, suncheck
calls:
This function takes in a list of element sets and returns a matrix of target numbers
and positions at the current time. It does this by using the sat vec function to determine
the location, followed by executing the checks on the position of the sun and earth.
sun check.m
input:
output:
calls:
sbv coordinates, sun coordinates, target satellite coordinates
0 for viewable, 1 for not viewable with respect to sun constraint
-none-
This function takes in the position of the SBV, sun, and target satellite, and
determines if the resulting sbv-target vector is a possible candidate for observation or if
the sun would interfere with the observation of the target at this orientation.
67
sun vec.m
input:
output:
calls:
t = time (in days)
[x,y,z] = sun's coordinates in the celestial coordinate system
-none-
This function models the orbit of the earth about the sun as a perfect circle (close,
eccentricity of orbit very small). Then , relative to the vernal equinox (equal to 1 st point
of Aries) at (estimated)12:00 am March
2 0
th
,2000, we calculate the [x,y,z] position of
the sun in the celestial coordinate system.
Stage 4: Choosing Best Orientation of SBV
The available satellites then need to be broken down into visible regions, with a
measure of how advantageous each region is when compared against other possible
regions. Thus, this stage is concerned with determining which region should be used for
the orientation of the SBV satellite, using the simple one-step look-ahead algorithm.
adi function.m
input:
output:
calls:
adjmatrix, proppath
single number = value of proposed path
-none-
This function takes in the proposed orientation of the sbv along with the satellites
that it would view with that orientation. It also takes in a matrix that holds a count on the
number of times a particular satellite has been viewed. It returns a value based on a given
68
function (can change this function) such that one can encourage/discourage various given
satellites, discourage viewing one satellite multiple times, etc.
find best.m
input:
output:
calls:
satellites matrix (format as returned by satavail), sbv (x,y,z) position at
the current time, current time, start time, cur-position matrix, adj_function
matrix.
same as withinangle: matrix containing the result of the view of this
particular angle off the y-axis. Each row is a different target2 satellite.
Row has the following format: [angle of target2 satellite, angle of z-axis
used, current time, comparison density, x-axis vector: (x,y,and z
coordinates) ,y-axis vector (x,y,and z coordinates), z-axis vector (x,y,z
coordinates), target1 number, target2 number] => 15 separate entries.
vec length, findortho, p3, adjfunction, within-angle
This function is used to distinguish between the various slant vectors that are
possible with the SBV orientation. It starts by setting the slant vector equal to the
difference between the SBV position and the 1 't satellite in the satellite matrix. We then
check the rest of the possible target satellites to see which are available to be viewed with
the given slant vector. If none are available, we choose an orientation based on transition
time to find the optimal orientation for that slant vector. Else, we compare the sbvtarget2 vector to the sbv-targetl vector. If the resulting angle between them is less than
5.6 degrees, an orientation exists that will cover both satellites. We then project target2
satellite to a point in the plane orthogonal to the slant vector at the point of target1. Next,
the angle between this projection point and the z-orientation vector (found by the 1 "
projected point found to the sbv) is determined. We then group all of the target2
candidates in a matrix, sorted by angle of rotation off given z-vector, and use
within-angle to determine the best orientation for each possible orientation. We iterate
69
through all possible slant vectors, and find the best orientation for each, and by
comparing these we find the best overall orientation at any given point in time.
find ortho.m
input:
output:
calls:
a vector x
a vector y orthogonal to the vector x
-none-
This helper function simply computes a vector y such that the dot product of x
and y is 0. This is used as a starting z-axis for a satellite orientation where only the target
satellite is in the field of view.
p3.m
input:
output:
calls:
coordinates for sbv, target satellite 1, and target 2 (or other point on the z
axis of the sbv orientation), and a normalization constant (c is used =
width of field of view at the target sat 1 distance from sbv for consistency)
[x,y,z] coordinates of a vector perpendicular to both the sbv-target 1 vector
and the target 1 -target2 vector (thus able to serve as a y axis)
-none-
This function is used to determine the y-axis vector of the sbv orientation, thus
requiring that this vector is orthogonal to the sbv-target 1 vector and to the target 1 -target2
vector. We take the cross product of these two vectors, and the result is normalized to
length c for consistency.
70
sat timin2.m
input:
output:
calls:
prev state (3*3 matrix of rowI = sbv orientation's xaxis, row2 = y_axis,
row3 = z_axis) and finalstate (same format as prevstate)
single number = time required for transition (in sec)
-none-
This function implements the heuristic developed by Lincoln Laboratory to
approximate the timing required to transition from a SBV orientation (prevstate) to a
second orientation (final-state). This simply requires a few operations on the matrices
involved to come up with an approximation.
within ang1e.m
input:
output:
real sat[i,:] = [ang of rotation off axis, position of sati, position of z-axis
point, position of y-axis (from x and z), targeti sat number, target2 sat
number] (i is in sorted order by ang of rotation off axis), current time, sbv
position, usepos (0 or 1), current position matrix (3*3), adjustment
matrix
matrix containing the result of the view of this particular angle off the yaxis. Each row is a different target2 satellite. Rows have the following
format: [angle of target2 satellite, angle of z-axis used, current time,
comparison density, x-axis vector: (x,y,and z coordinates) ,y-axis vector
(x,y,and z coordinates), z-axis vector (x,y,z coordinates), target1 number,
target2 number] => 15 separate entries.
calls:
vec length, sunvec, sat-timing, adj_function
This function carries out a good deal of the computation involved with
determining the final path. We take in a list of possible satellites that can be viewed with
the SBV slant vector (x-vector) in a particular orientation. This is given from the
findbest function, and is modeled as a circle spanned at the SBV-targetl distance with a
radius equivalent to the 5.6 degree spanning angle of the 4 CCD's. Once we have this
list, the task remains to decide which orientation of the y and z SBV orientation vectors
71
will give the optimal result. To do so, we set the lower angle of the SBV orientation
equal to each of the rotation angles of the satellites. We then check to see if the adjacent,
higher-valued angles are within the viewing range of the SBV, including a check on the
crossover from 211 to 0 radians after one complete circle.
For each candidate orientation, we thus have a list of all of the target satellites that
would be viewable. We decide on the orientation used by averaging the high and low
angles of each proposed orientation, and using that as the new SBV z-orientation vector.
The y-vector is orthogonal to the x and z orientation vectors, and is arranged to always
point away from the sun. Then, the x,y,z orientation vectors are all normalized. Further,
if a previous orientation is given (i.e. current time is not equal to start time, denoted by
use pos bit), then we find the transition time from the previous orientation to the new
orientation.
Finally, we use the adjfunction to find a comparison value based on how many
satellites are to be viewed, how many have already been viewed (and how often), and
incorporating the travel time between orientations. If we do not have a previous
orientation, we simply find the orientation that views the most satellites. We do not need
to worry about previously viewed satellites, as this is only used with no previous
orientation, i.e. there are no previously viewed satellites. Eventually, a function to
determine importance of each satellite might be useful, and could be incorporated here as
well.
Using the comparison value, or the number of viewable satellites as in first
orientation sequence, we can return the maximum orientation given a particular slant
72
vector, as well as the comparison value that was found, currenttime, current orientation,
etc.
Stage 5: Simulations:
ind it.m
input:
output:
calls:
-none-nonenewton, findp, period
This script is used to test the effectiveness of the newton function at finding the
eccentric angle. It is also used to test the speed of the calculation. By altering the
varying tolerances of the newton method, as well as the points to be considered, we can
analyze the breakdown of newton with low tolerance, and thus support the need for high
accuracy in this stage. We can also compare the benefit of relative vs. absolute error.
This is shown on the resulting plot, which is eccentric angle vs. number of points past
perigee.
ind it2.m
input:
output:
calls:
-none-nonereadin, findp, eccangle, period
Essentially the same script as indit, except that now we are checking to be sure
that the readin function and ecc_angle work correctly and give the same results as if the
information was extracted by hand - simply a check for errors.
73
ind it3.m
input:
output:
calls:
-none-nonereadin, findp, period
This function tests the effectiveness of the orbit xy program by using the newton
function to find the eccentric angle at each point in time, runs the function through a
period, and displays the resulting graph of the x-y position. We would like to see varying
elliptic orbits about the earth, and indeed this is the result.
ind it4.m
input:
output:
calls:
-none-nonereadin, findp, period, satvec
This script is equivalent to ind_it3 except that we are aiming to test the transition
to 3-dimensional coordinates. We thus use satvec as our sub-function, find the (x,y,z)
position of a variety of satellites, and plot them vs. sbv orbit and a model of the earth (a
sphere with radius = earth's approx. radius)
rand best.m
input:
output:
calls:
same as findbest, except additional matrix argument for omitting
satellites from consideration for resulting path.
same as findbest
same as findbest
74
This procedure is identical to findbest except that it has the additional features of
being able to exclude satellites from consideration based on the additional input matrix.
It was also adapted to allow for random choice of satellite orientation for that analysis.
simL.m
input:
output:
calls:
start time and end time in days, number of satellites to consider
-nonereadin, satvec, vec length, earthcheck, sun_vec, sun check
This is the first functioning simulation of the process of propagating the orbits and
selectively eliminating the ones that are not visible at any given point in time. The
satellite positions are calculated at the current time, the positions are checked against the
sun and earth constraints, and the passing orbits counted. The viewable satellite count is
then displayed, the time is incremented by 1 day, and the process continues until the end
time is reached. At one time an attempt was made to verify the process by viewing the
vectors, but the 3D display was inconclusive. Thus, the verification is currently left to
mathematical analysis of the procedure, with other tests added as discovered.
sim2.m
input:
output:
calls:
start time and end time in days, number of satellites to consider
matrix of the best path of orientations from start time to end time with
given number of satellites
readin, sat_vec, satavail, findbest
This function simply takes in the start and end times of the simulation as well as
the number of satellites to observe. It then reads in the satellite element sets with readin,
initializes the adjustment matrix, and finds the available satellites with a call to sat-avail.
75
Next, it finds the best orientation at the current time with a call to findbest, updates the
current time as well as the adjustment matrix, and repeats until it reaches the end time
given.
test.m
file name (containing current path), start and stop segments of test (runs
sequentially), number of tests per segment
files containing new paths and their figures of merit compared to current
paths figure of merit
readin, satvec, randbest, findbest
input:
output:
calls:
This script runs the tests of the iterative improvement algorithm. It first loads the
current path and calculates a figure of merit for that path. Then, it copies the current path
up to the first point of the test to the result. It finds the appropriate transition to the new
orientation by calling rand-best. Then, it calls findbest repeatedly to fill the next 10 min
of SBV path time. Finally, it pastes the end of the current path to the result. It calculates
the resulting figure of merit and prints the result to a file. This process is repeated as
many time per transition point as given in input, for each of the points in the range of the
input transition points.
General Functions
vec length.m
input:
output:
calls:
vector end point and origin point.
single number = length of vector from given origin
-noneThis function takes in a target point and an origin point and computes the length
of the vector between them.
76
Appendix 2: Code Modules
This section contains the actual code modules used for this thesis. This is included
solely for completeness, and in the event these modules would be applicable for future
testing. Appendix 1 should be referenced for any information on the structure of the code
that is not clear in this section. This section presents all of the code modules in
alphabetical order (MATLAB code):
adj-function.m:
function res = adjfunction(adjmatrix,proppath);
%This function will give a numeric result for a proposed path, such that any duplication of target
%satellites will be discouraged
temp I = proppath(l, 11);
t] = size(adj matrix);
t2 = tl(1);
t3 = size(prop_path);
t4 = t3(l);
val= -1;
for k = l:t2
if adjmatrix(k,1) == temp I
val = (1/adjmatrix(k,2));
end
end
if val == -1
fprintf('Error in adjustment function!!! \n');
%cause an error to be given
nrr;
end
%check to see if more than
1 satellite is targeted
if tempi ~ proppath(1,12)
%ifyes, add in additional value for this view
for k'= 1:t4
temp I = proppath(k, 12);
form=
1:t2
if adjmatrix(m, 1) == temp I
val = val + (l/adjmatrix(m,2));
end
end
end
end
res = val;
77
catsort.m:
%Script to take catl.txt (full catalog of all element sets to be considered) and
%pick only those with acceptable orbits (3-25 earth radii, <.9 eccentricity)
test = readin('catl.txt');
fid = fopen('data_new.dat','wt')
fid2 = fopen('datlist.dat','wt')
sl = size(test);
fork=1 :sl;
%check earth radii (between 3 and 25)
if test(k,7) >3;
if test(k,7) < 25;
%check eccentricity
if test(k,4) < .9;
%check epoch date
if test(k,9) > 98;
if test(k,8) > 350;
fprintf('here /n');
fprintf(fid,'%s %d %6.7f %6.7f %6.7f%6.7f %6.7f %6.7f %6.7f %d %s
\n','ign',test(k, I ),test(k,2),test(k,3),test(k,4),test(k,5),test(k,6),test(k,7),test(k,8),test(k,9),'ign');
fprintf(fid2,'%d %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f %d
\n',test(k, I ),test(k,2),test(k,3),test(k,4),test(k,5),test(k,6),test(k,7),test(k,8),test(k,9));
end;
end;
end;
end;
end;
end;
fclose(fid);
fclose(fid2);
earthcheck.m:
function res = earth check(a,b,c);
%function to see if the SBV sat vector is through the earth
%a = earth -> SBV, b = earth -> Satellite, c = SBV -> sat (vector shifted to origin)
%result of 0 is good, result of I indicates path is through earth.
%assumes a is greater than earth's radius
alpha-critical = asin(6378.14*1000/a);
alpha = acos((a^2+c^2-b^2)/(2*a*c));
if alpha > alpha_critical;
res =0;
else
res = 1;
end
eccanom.m:
function E = eccanom(el,t);
%Function for taking input time t and element set el and returning eccentric anomaly
%t is time, x is satellite number, el is element set for satellite x, all 9 entries from standard table
%At time t, where is this satellite pointing?
%e,T,t,a needed as arguments for Newton
e = el(4);
78
eccanom.m (cont.):
T =el(8);
a =el(7);
m = el(6);
E
=
newton(e,t,T,a,m);
find best.m:
function res = find best(sats,sbv,currenttimestart time,cur_pos,adj matrix);
%This function will find the best orientation for the sbv given the available satellites to observe
ss = size(sats);
s_use = ss(I);
max_view = 0;
overall_max = 0;
clear stagemax;
stagemax = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for iter = I:suse
fprintf('checking sat %d \n',iter);
clear viewable;
clear tempsat;
count2 =
1;
%fprintf('Starting iteration %d \n',iter);
satl = sats(iter,:);
sat l c = [satI(2),satI(3),sat1(4)];
countl = 1;
alpha critical = (5.6/360)*(2*pi);
v_sat Isbv = vec_length(sat Ic,sbv);
for k = l:suse
if k -= iter
satk = sats(k,:);
satkc = [satk(2),satk(3),satk(4)];
v_satl _satk = veclength(sat lc,satkc);
v_satksbv = veclength(satkc,sbv);
alpha = acos((v_sat I_sbv^2+v_satksbv^2-v satIsatk2)/(2*vsatIsbv*v-satksbv));
if alpha < alphacritical;
if alpha ~ 0;
viewable(countl,:) = satk;
countI = countl + 1;
end;
end;
end;
end;
fprintf('Count I is %d \n',countl);
if countI ==
1
%With one satellite in the field of view, we have two options. If this is the first orientation,
%we currently do not project timing constraints, so we can simply use the first orientation as a
%best fit. Else, we check the orientations rotated about the x-axis in 10 degree (can be changed)
%intervals.
if start-time == current-time
iterang = 1;
else
iterang = 36;
end
%only have one satellite in field of view (the original target satellite)
origin = [0,0,0];
79
findbest.m (cont.):
slantvec = sat Ic - sbv;
v I = vec_length(slantvec,origin);
x_use = slantvec/vi;
c = vI*tan(5.6*(pi/180));
for runit = I:iter-ang;
%find any vector orthogonal to x_use
z-temp = findortho(xuse);
ztrans = z-temp/(veclength(ztemp,origin));
z_point = satIc + ztrans*c;
y_temp I = p3(sbv,sat 1c,zpoint,c);
y temp2 = ytemp I - sat l c;
v2 = vec_length(origin,ytemp2);
y trans = ytemp2/v2;
%rotate the zpoint vector by (runit* I 0)*2pi/360)
ang-useI = runit*1O*pi/180;
xtI = cos(ang-use l);
xt2 = sin(anguse l);
%We now transform the x,y axis by the rotation angle anguse
z_trans = z_trans*(xtl) + ytrans*(xt2);
ytrans = z_trans*(-xt2) + ytrans*(xtl);
%Need to decide whether to orient the satellite toward +- y trans, given the current position
%of the sun.
sun_now = sun vec(current time);
sat I c_tosun = sunnow - sati c;
%turn satIc to sun vector into unit length
unitl = veclength(originsatl c_to_sun);
st-sun = (sati c_to_sun/unitI);
%check that the sun-sat I vector is unit length, use for angorient calculation
stsunI = veclength(origin,st sun);
%find length of vector between sun-sat I and ytrans
p3_sun = veclength(st-sun,ytrans);
%check that yt is unit length, use for angorient
yt = veclength(origin,ytrans);
angorient = acos((st sun_l^2+yt^2-p3_sun^2)/(2*st sun_l*yt));
%Get unit vector representing direction from sby to target satellite
xuse temp l = sat l c - sbv;
adjI = veclength(origin,xusetempI);
if ang orient > pi/2
yuse = ytrans;
%Now, we want to slide the xuse_temp vector to the center of the 3rd ccd => slide by
%2.1 degrees
slide = 2.l*(pi/180);
hold 1 z-trans*adj I *tan(slide);
point4 = sat I c + holdI;
hold2 = point4-sbv;
hold3 = veclength(sbv,point4);
hold4 adj I *cos(slide);
point5 = sbv + (hold4/hold3)*hold2;
x use hold2/hold3;
z_use = (sat 1c-point5)/vec_length(sat 1c,point5);
80
find best.m (cont.):
%For checking purposes on orthogonality/length
%tI = veclength(origin,x use);
%t2 = veclength(origin,yuse);
%t3 = veclength(origin,zuse);
%t4 = veclength(xuse,yuse);
%t5 = veclength(zuse,yuse);
%t6 = veclength(xuse,zuse);
%x-use
%yuse
%z use
%acos((t I^2+t2^2-t4A2)/(2*t I *t2))
%acos((t2A2+t3^2-t5A2)/(2*t2*t3))
%acos((t3^2+tl A2-t6A2)/(2*t3*tl))
else
yuse = -y-trans;
%Now, we want to slide the x use temp vector to the center of the 2rd ccd => slide by
%3.5 degrees
slide = 3.5*(pi/180);
hold] = ztrans*adj I *tan(slide);
point4 =sat]c + hold1;
hold2 = point4-sbv;
hold3 = veclength(sbv,point4);
hold4 = adj 1*cos(slide);
point5 = sbv + (hold4/hold3)*hold2;
x use = hold2/hold3;
z-use = (point5-sat 1c)/veclength(sat I c,point5);
%For checking purposes on orthogonality/length
%t l = vec length(origin,x_use);
%t2 = veclength(origin,yuse);
%t3 = veclength(origin,zuse);
%t4 = vec length(x use,yuse);
%t5 = vec_ length(z_use,y_use);
%t6 = veclength(xuse,zuse);
%xuse
%yuse
%zuse
%acos((t I^2+t2^2-t4A2)/(2*t I*t2))
%acos((t2^2+t3A2-t5A2)/(2*t2*t3))
%acos((t3A2+t IA2-t6^2)/(2*t3*t l))
end
%Now, orientation of satellite at this point is xuse, y use, zuse.
%Need to find timing constraint, iterate for different angles about target in future
%Have picked random orientation, find its comparison value
temppath = [O,x use,y-use,zuse,sat 1(1 ),sat 1(1)];
comparetemp = adjfunction(adjmatrix,temppath);
if starttime == currenttime
time] = 1;
else
newpos = [xuse;yuse;zuse];
81
findbest.m (cont.):
time I = sattiming(curpos,newpos);
end
compare =comparetemp/time I;
if compare > overall_max
bestone =[0,0,current time,compare,x use,yuse,zuse,sat I(1 ),sat I(1)];
overall-max = compare;
end
end
end
if count] > I
%Now, we need to set up the new coordinate axis
xaxistot = viewable(l,:);
%removing the satellite number from set
xaxis = [xaxis tot(2),xaxistot(3),xaxistot(4)];
%we find the length of the slant vector
I = veclength(satlc,sbv);
%We now find the range (in distance) of the optical sensor of the sbv
c = l*tan(5.6*(pi/180));
%Find the distance from sby to satk for xaxis satellite
sbvsat2 = veclength(sbv,xaxis);
%This is the distance from the sbv to the projection of sat2 to the perpendicular
%plane to sbv-satl.
v_sat Isatk veclength(satlc,xaxis);
v_sat Isbv veclength(satlc,sbv);
vsatk_sby = veclength(xaxis,sbv);
alpha = acos((vsatl _sbv2+vsatksbvA2-v_sat _satk^2)/(2*vsatlsbv*vsatk_sbv));
sbvproj = l*tan(alpha);
sbvxpoint = (A2 + (sbv_proj)A2)A.5;
%Can use this to find the projection point (x,y,z)
xl = sbv(l) + (sbvxpoint/sbvsat2)*(xaxis(l) - sbv(l));
yl = sbv(2) + (sbv_ xpoint/sbvsat2)*(xaxis(2) - sbv(2));
zI = sbv(3) + (sby xpoint/sbvsat2)*(xaxis(3) - sbv(3));
xtemp = [x l,y l,zl];
%Need vector length to be = c??????
x2 = satlc(l) + (c/sbvproj)*(xtemp(l) - satlc(l));
y2 = satIc(2) + (c/sbvproj)*(x temp(2) - satIc(2));
z2 = sat l c(3) + (c/sbv_proj)*(xtemp(3) - sat l c(3));
point2 = [x2,y2,z2];
point3 = p3(sbv,satlc,point2,c);
%shows that they are orthogonal and
%vec length(satl c,point2);
%vec length(sat 1c,point3);
%vec-length(point2,point3);
=
c
%vec length(sbv,sat I c)
%vec length(sbv,point3)
%vec-length(satIc,point3)
%vec length(sbv,sat I c)
%vec length(sbv,point2)
%vec-length(satIc,point2)
temp 1= size(viewable);
82
find best.m (cont.):
temp2 = temp 1(1);
for n = I:temp2;
%now we need to find the angle from each satellite to the reference
xaxistot = viewable(n,:);
%removing the satellite number from set
xaxis = [xaxistot(2),xaxistot(3),xaxistot(4)];
%we find the length of the slant vector
I = veclength(satlc,sbv);
%We now find the range (in distance) of the optical sensor of the sbv
c = l*tan(5.6*(pi/180));
%Find the distance from sbv to satk for xaxis satellite
sbvsat2 = veclength(sbv,xaxis);
%This is the distance from the sbv to the projection of sat2 to the perpendicular
%plane to sbv-satl.
v_sat Isatk = veclength(satIc,xaxis);
v sat Isbv = veclength(satIc,sbv);
vsatksbv = veclength(xaxis,sbv);
alpha = acos((v_satl_sbvA2+vsatksbv^2-v-satl-satk^2)/(2*vsatl-sbv*v
satk-sbv));
sbv_proj = l*tan(alpha);
sbvxpoint = (J^2 + (sbvproj)^2)A.5;
%Can use this to find the projection point (x,y,z)
x I = sbv(l) + (sbvxpoint/sbvsat2)*(xaxis(l) - sbv(l));
y I = sbv(2) + (sbv_ xpoint/sbvsat2)*(xaxis(2) - sbv(2));
zl = sbv(3) + (sbvxpoint/sbvsat2)*(xaxis(3) - sbv(3));
x_proj = [x l,y l,zI];
%Use satl c,point2,xtemp
vl I = vec length(sat Ic,xproj);
v12 = vec length(sat Ic,point2);
v 13 = vec-length(xproj,point2);
alpha= acos((vl I^2+v12^2-v13^2)/(2*v II*v12));
if -isreal(alpha)
%Occasionally the innacuracy of the calculation will cause acos(l+). Since this
%is not geometrically possible, we get a complex answer. The magnitude is small
%however, as innacuracy is small. Thus, we take the real part = 0.
alpha = real(alpha);
end;
%Use sat 1c,point3,xtemp
v21 = vec length(sat I c,xproj);
v22 = vec length(sat I c,point3);
v23 = vec-length(xproj,point3);
alpha2 = acos((v21^2+v22^2-v23^2)/(2*v2l*v22));
if alpha2 > (pi/2)
alpha = (2*pi) - alpha;
end
temp sat(count2,:) = [alpha, sati c, point2, point3,sat1(l),xaxistot(I)];
count2 = count2 + 1;
%fprintf('alpha is %6.1Of \n',alpha);
end;
83
findbest.m (cont.):
%Using Insertion sort to order tempsat by alpha (only around 25 sat/field max right now)
%Might implement recursive sorting if needed later
%set up initial conditions for sorting algorithm
count3 =
1;
s3 = size(temp sat);
s3a = s3(l);
clear realsat
form= 1:s3a;
%set the initial max to be the first element
t-maxhold
= tempsat(I,:);
t_max t-max-hold(l );
a_max =l;
fork= l:s3a;
tl = tempsat(k,:);
if t1(I) > t-max;
t_max= tl(1);
a_max= k;
end;
end;
real sat(count3,:) = tempsat(a max,:);
remem = tempsat(amax,:);
rI = remem(l);
%reinsert result into temp matrix, only negative angle => will not be reconsidered
tempsat(a max,:) = [-r l,satlc,point2, point3,sat1(1),xaxistot( )];
count3 = count3 +
1;
end;
%Now, real sat contains the sorted element list for the particular view.
%We want to find if any are in the same field of view
if (current time == starttime)
usep = 0;
else
usecp = 1;
end
bestone withinangle(real_satcurrenttimesbvusep,curpos,adj
compare = best one(1,4);
matrix);
%fprintf('here sats %d %d compare = %d\n', best one(1 ,14),best one(l ,1 5),compare);
if compare > overallmax
stage max = bestone;
overallmax = compare;
end
end;
end;
res = stage max
84
findortho.m:
function res = find_ortho(x)
if x(3) ~ 0
temp = -x(l) - x(2);
res = [1,1,(temp/(x(3)))];
elseif x(2) ~ 0
temp = -x(I) - x(3);
res = [1,(temp/x(2)),1];
elseif x(l) ~ 0;
temp = -x(2) - x(3);
res = [(temp/x( 1)), 1,11;
else
fprintf('x is origin vector > illegal slant vector!!! \n');
%cause error to be thrown
ertretrg
end
findp.m:
function tp = findp(a,m,te);
%Calculates the time that a satellite will reach perigee given the semi-major axis a,
%the time of epoch te and the anomaly at epoch m: find_p(a,m,te);
mp = mcalc(a);
m2 = m*(2*pi/360);
t_use = te*24*60*60;
tptemp = tuse - (m2/mp);
tp = tptemp/(24*3600);
ind_it.m:
%Simply uses the newton function to check the accuracy (by plot) of the resulting eccentric anomaly
clear ind;
clear outl;
time] = clock;
for k = 50001:51200;
%ind(k) = find_p(1.3539966,150.506,354.8648120) + (k*period(1.3539966)/300- period(l.3539966)/600);
%ind(k) = findp(9.1005951,183.192,344.2102160) + (k*period(9.1005951)/300 - period(9.1005951)/600);
ind(k) = findp(3.1363282,151.620,354.9) + ((k*period(3.1363282))/300 - period(3.1363282)/600);
end;
for k = 50001:51200;
outi(k-50000) = newton(.664793,ind(k),354.9,3.1363282,151.62);
%outl(k) = newton(.873969,ind(k),344.210216,9.1005951,183.192);
%out I(k) = newton(. 185883,ind(k),354.8648120,1.3539966,150.506);
end
%EX 00675 35.900 190.405 0.873696 179.578 183.192 9.1005951 344.2102160 64 SPD
%EX 00005 34.247 211.266 0.185883 200.867 150.506 1.3539966 354.8648120 99 SPD
%EX 02643 25.963 241.370 0.664793 28.797 151.620 3.1363282 354.9000000 99 LBO
time2 = clock;
time2-time I
f= [50001/300: 1/300: 5 1200/300];
plot(f,(outl/(pi)));
85
ind_it2.m:
%Simply uses the newton function to check the orbit I function
clear ind;
clear outI;
sat = readin('data new.dat');
numI = 675;
si = size(sat);
s2 = sl(l);
fork= l:s2;
if sat(k) == num I;
el = sat(k,:);
end;
end;
el = sat(4,:);
fork= 1:1200;
ind(k) = find p(el(7),eI(6),el(8)) + (k*period(el(7))/300 - period(el(7))/600);
%ind(k)= find_p(9.1005951,183.192,344.2102160) + (k*period(9.1005951)/300 - period(9.100595 ])/600);
%ind(k) = findp(3.1363282,151.620,354.9) + (k*period(3.1363282)/300 - period(3.1363282)/600);
end;
for k = 1:1200;
outI(k) = eccanom(el,ind(k));
%out] (k) = newton(.873969,ind(k),344.210216,9.1005951,183.192);
%out] (k) = newton(.185883,ind(k),354.8648120,1.3539966,150.506);
end
plot(outl, 'r');
%EX 00675 35.900 190.405 0.873696 179.578 183.192 9.1005951 344.2102160 64 SPD
%EX 00005 34.247 211.266 0.185883 200.867 150.506 1.3539966 354.8648120 99 SPD
%EX 02643 25.963 241.370 0.664793 28.797 151.620 3.1363282 354.9000000 99 LB0
ind_it3.m:
%Simply uses the newton function to check the orbit I function
clear ind;
clear outl;
sat
=
readin('data-new.dat');
size(sat);
sl(1);
si
s2
=
s2
=30;
=
form=
1:s2;
m
el = sat(m,:);
for k = 1:201;
ind(k)= findp(el(7),el(6),el(8)) + (k*period(el(7))/200 - period(el(7))/200);
%ind(k)= findp(9.1005951,183.192,344.2102160) + (k*period(9.1005951)/300 - period(9.1005951)/600);
%ind(k) = findp(3.1363282,151.620,354.9) + (k*period(3.1363282)/300 - period(3.1363282)/600);
end;
for n = 1:20 1;
outI(n,:) = orbit xy(el,ind(n));
end
x = out l(:,1);
86
ind_it3.m (cont.):
y = out](:,2);
plot(x,y);
hold on;
%fprintf('At %6.3f: ',m);
%r = input('Continue?');
end;
ind it4.m:
%Simply uses the newton function to check the satvec function
clear ind;
clear outl;
sat = readin('data-new.dat');
%numl = 2643;
%test satellites are 5,675,2643;
sI = size(sat);
s2 = sl(1);
time I = clock;
%fork=
1:s2;
%if sat(k) == numI;
%el = sat(k,:);
%end;
%end;
%EX 23851 99.394 21.704 0.000700 269.649 90.387 1.1410727 355.2082490 99 SPD
sbv = [23851, 99.394, 21.704, .000700, 269.649,90.387,1.1410727, 355.2082490, 99];
for 1= 1:10;
clear temp 1;
el = sat(l,:);
fork = 1:600;
ind(k) = findp(el(7),el(6),el(8)) + (k*period(el(7))/300 - period(el(7))/600);
end;
for k = 1:600;
temp 1(k,:) = sat vec(el,ind(k));
end;
plot3(temp
l(:, 1),templ(:,2),
temp 1 (:,3));
hold on;
end;
el
=
sbv;
clear temp 1;
fork= 1:600;
ind(k) = findp(el(7),el(6),el(8)) + (k*period(el(7))/300 - period(el(7))/600);
end;
fork = 1:600;
temp 1(k,:) = sat_vec(el,ind(k));
end;
plot3(templ(:,l),tempI(:,2), temp1(:,3),'r');
hold on;
87
ind_it4.m(cont.):
grid on;
[x,y,z] = sphere;
x = x*l000*6378.14;
y = y*l000*6378.14;
z = z*1000*6378.14;
surf(x,y,z);
time2 = clock;
time2-time I
mcalc.m:
function n = mcalc(a);
%Calculates the coefficient n in m = n(t-Tp), mcalc(a)
%a is semimajor axis
%universal constant of gravitation: 6.668*10^-l 1
%mass of Earth = 5.98*10^24
%mass of satellite neglected
a = a*1000*6378.14;
k = ((6.668*10^(-l 1)) * (5.98 * 10^24))^.5;
n = k * (a)^(-l.5);
newton.m:
function eccangle = newton(e,t,T,a,m);
%Newton's method
%To find M: need a,T,t
%To solve Keppler's equation: need M,e
%e,T,a,m available in element set matrix
%t to be input from user function
tol= .0000001;
%tol=.001;
iter = 50;
runs = 1;
%convert from multiple of earth radii to km to m
a_use = a*6378.14* 1000;
%calculate the additional angle of M from current time
Mtemp = mcalc(a-use,T,t);
%convert base m to radians from degrees
mp = ((2*pi)/360) * m;
%add base m to additional m for total
M_use = mp + Mtemp;
m in Kepplers
equation
%fprintf('Muse is %f\n',M_use);
guess = 1;
while runs <= iter
%Newtons approximation
FA = guess - (temp(guess,e,M use)/deriv(guess,e));
%Check the tolerance of error
if FA -= 0;
if (abs(FA-guess))/(abs(FA))< tol;
88
newton.m (cont.):
%if abs(temp(FA,e,Muse)) < tol
%fprintf('Method succeeded in %i iterations to %6.1Of\n', runs,FA);
ecc_angle = mod(FA,(2*pi));
%eccangle = FA;
return;
end;
end;
if FA == 0;
if (abs(FA-guess)) < tol;
eccangle = mod(FA,(2*pi));
return;
end;
end;
%Increment the routine counter
runs = runs + 1;
%Update the guess for another round.
guess = FA;
end
%try new guess for cases where above falls through (purely guess at this stage)
guess = FA- 1;
runs = 1;
%fprintf('Using 2nd guess \n');
while runs <= iter
%Newtons approximation
FA = guess - (temp(guess,e,Muse)/deriv(guess,e));
%Check the tolerance of error
if FA ~ 0;
if (abs(FA-guess))/(abs(FA)) < tol;
%fprintf('Method succeeded in %i iterations to %6. 1Of\n', runs,FA);
ecc_angle = mod(FA,(2*pi));
%eccangle = FA;
return;
end;
end;
if FA == 0;
if (abs(FA-guess)) < tol;
eccangle = mod(FA,(2*pi));
return;
end;
end;
%Increment the routine counter
runs = runs + 1;
%Update the guess for another round.
guess = FA;
end
%fprintf('Using 3rd guess \n');
guess = FA+.75;
runs= 1;
while runs <= iter
89
newton.m(cont.):
%Newtons approximation
FA = guess - (temp(guess,e,Muse)/deriv(guess,e));
%Check the tolerance of error
if FA = 0;
if (abs(FA-guess))/(abs(FA)) < tol;
%fprintf('Method succeeded in %i iterations to %6. 1Of\n', runs,FA);
ecc_angle = mod(FA,(2*pi));
%eccangle = FA;
return;
end;
end;
if FA == 0;
if (abs(FA-guess)) < tol;
ecc_angle = mod(FA,(2*pi));
return;
end;
end;
%Increment the routine counter
runs = runs + 1;
%Update the guess for another round.
guess = FA;
end
for runit = 1:50;
%fprintf('Using round guess \n');
guess = runit/(2*pi);
runs = 1;
while runs <= iter
%Newtons approximation
FA = guess - (temp(guess,e,Muse)/deriv(guess,e));
%Check the tolerance of error
if FA ~ 0;
if (abs(FA-guess))/(abs(FA)) < tol;
%fprintf('Method succeeded in %i iterations to %6. 1Of\n', runs,FA);
ecc_angle = mod(FA,(2*pi));
%ecc_angle = FA;
return;
end;
end;
if FA == 0;
if(abs(FA-guess)) < tol;
eccangle = mod(FA,(2*pi));
return;
end;
end;
%Increment the routine counter
runs = runs + 1;
%Update the guess for another round.
guess = FA;
end;
end
90
newton.m(cont.):
fprintf('Error in Newtons method - did not return within %i iterations \n', runs);
return;
%-------------------
function res = temp(x,e,M)
%Keppler's equation, x is eccentric angle, a is eccentricity, M is from mcalc
res = x - e*sin(x) - M;
%------------------------
function res = deriv(x,e)
%derivative for Newtons approximation
res = I-e*cos(x);
%----------------------
function res = mcalc(a,T,t);
%a is semimajor axis, T is point of epoch, t is time desired
%universal constant of gravitation: 6.668 *10^- 11
%mass of Earth = 5.98*10^24
%mass of satellite neglected
k
((6.668*10^(-l 1)) * (5.98 * 10^24))^.5;
n = k * (a)^(-].5);
%convert time difference from days to seconds
t_use = (t-T)*24*60*60;
res = n*tuse;
%fprintf(Additional angle is %5f\n',res);
orbitxy.m:
function
loc = orbitxy(el,t);
%function to determine the location of the satellite (x,y in orbital plane)
%with element set el at time t. loc = orbit xy(t,el)
E = eccanom(el,t);
%convert to meters instead of earth radii
a = el(7)*1000*6378.14;
e = el(4);
r = a*(l-e*cos(E));
x = a*(cos(E) - e);
y = a*((l-(eA2))A.5)*sin(E);
w
= xA2 + y^2;
z =r^2;
%relatively high tolerance due to magnitude of numbers (10^ 9 or more)
%should be careful about ramifications of this error. For large sat orbits (20 earth
%radii +, very easy to get minor error (100 or so). function should be fine, but check
%errors just in case.
if abs(w-z) > 100
fprintf('ERROR IN ORBITXY!!!!!!!\n');
end;
loc(l)= x;
loc(2) = y;
91
p3.m:
function res = p3(sbv,satl c,point2,c);
sat I c_sbv = sbv-sat Ic;
sat Ic_point2 = point2 - sat Ic;
%taking cross product to find 3rd point
p3_x = satl cpoint2(2)*satl c sbv(3) - sat lcpoint2(3)*satl csbv(2);
p3_y = sat l _point2(3)*satlc_sbv(l) - sat c _point2(l )*satl c sbv(3);
p3_z = satic_point2(1)*satlc_sbv(2) - satlc_point2(2)*satlc_sbv(l);
po3 = [p3_x,p3_y,p3_z];
%normalize to c
v = veclength(sat I c,po3);
p3_1 = satlc(1) + (c/v)*(p3 x - satlc(l));
p3_2 = satlc(2) + (c/v)*(p3_y - satlc(2));
p3_3 = sat lc(3) + (c/v)*(p3 z - satlc(3));
res = [p3_1,p3_2,p3_3];
period.m:
function sat per = period(a);
%function to calculate the period time of an orbit (in days).
%period(a) where a is the semi-major axis (in earth radii)
%Constants: G is univ. cons. of gravitation, M = mass of earth, R is earth radii.
G = 6.668* 10^(-1 1);
M = 5.98 * 10^24;
R =6378.12;
tempI = (G*M/((a*R*1000)^3))^.5;
temp2 =2*pi/templ;
sat per = temp2/(60*60*24);
randbest.m:
function res = rand best(sats,sbv, currenttime,start-time,c ur_pos,adjmatrix,cur sat);
%This function will find the best orientation for the sbv given the available satellites to observe
ss = size(sats);
suse = ss(1);
maxview = 0;
overall-max = -1;
clear stagemax;
stage max = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
%rand('state',sum(i 00*clock));
%iter = round(rand(l)*suse);
for iter =
1:suse
hr = size(cur sat);
hr2 = hr(1);
checkme= 1;
for hrun =
1:hr2
if cur sat(hrun) == sats(iter,1);
checkme = 0;
end;
end;
92
randbest.m(cont.):
if checkme ==
1;
fprintf('checking sat %d \n',iter);
clear viewable;
clear tempsat;
count2 = 1;
sati = sats(iter,:);
satlc
[satl(2),satl(3),satl(4)];
=
countl = 1;
alpha critical = (5.6/360)*(2*pi);
v_sat Isbv = vec length(sat Ic,sbv);
fork= l:s use
if k ~ iter
satk = sats(k,:);
satkc = [satk(2),satk(3),satk(4)];
v sat Isatk = veclength(satc,satkc);
v_satk_sby = veclength(satkc,sbv);
alpha = acos((v satlsbv^2+vsatksbv^2-vsati_satk^2)/(2*v satisbv*v_satk_sbv));
if alpha < alpha_critical;
if alpha ~ 0;
viewable(countl,:) = satk;
count] = countl + 1;
end;
end;
end;
end;
if countl == I
%With one satellite in the field of view, we have two options. If this is the first orientation,
%we currently do not project timing constraints, so we can simply use the first orientation as a
%best fit. Else, we check the orientations rotated about the x-axis in 10 degree (can be changed)
%intervals.
if start-time == current-time
iterang= ;
else
iter-ang = 36;
end
%only have one satellite in field of view (the original target satellite)
origin = [0,0,0];
slantvec = satIc - sbv;
v I = veclength(slant-vec,origin);
x_use = slantvec/vI;
c = vI*tan(5.6*(pi/180));
for runit = 1:iter ang;
%find any vector orthogonal to x use
z_temp = findortho(x use);
z_trans = ztemp/(veclength(ztemp,origin));
z_point = satIc + z trans*c;
y_tempI = p3(sbv,sat I c,zpoint,c);
y_temp2 = ytemp I - sat I c;
v2 = vec length(origin,ytemp2);
ytrans = ytemp2/v2;
%rotate the zpoint vector by (runit* I 0)*2pi/360)
ang-usel = runit*I0*pi/180;
xtl = cos(angusel);
xt2 = sin(anguse l);
93
randbest.m(cont.):
%We now transform the x,y axis by the rotation angle anguse
z_trans = z_trans*(xtl) + ytrans*(xt2);
y_trans = z_trans*(-xt2) + ytrans*(xt l);
%Need to decide whether to orient the satellite toward +- y trans, given the current position
%of the sun.
sunnow = sunvec(current time);
satlc tosun = sun-now - satic;
%turn sati c to sun vector into unit length
unit I = veclength(origin,sat I ctosun);
stsun = (sat I ctosun/unit I);
%check that the sun-sat I vector is unit length, use for ang orient calculation
stsun_l = veclength(origin,st sun);
%find length of vector between sun-satl and ytrans
p3_sun = veclength(stsun,ytrans);
%check that yt is unit length, use for angorient
yt = veclength(origin,ytrans);
angorient = acos((st sunl^2+yt^2-p3_sun^2)/(2*stsunI*yt));
%Get unit vector representing direction from sbv to target satellite
x_usetempI = sat I c - sbv;
adj I = veclength(origin,xusetemp1);
if angorient > pi/2
y_use = ytrans;
%Now, we want to slide the x_usetemp vector to the center of the 3rd ccd => slide by
%2.1 degrees
slide = 2. 1 *(pi/180);
hold I = z_trans*adj I *tan(slide);
point4 = satIc + holdI;
hold2 = point4-sbv;
hold3 = veclength(sbv,point4);
hold4 = adj I *cos(slide);
point5 = sbv + (hold4/hold3)*hold2;
x-use = hold2/hold3;
z_use = (satIc-point5)/veclength(satl c,point5);
%For checking purposes on orthogonality/length
%tl = veclength(origin,xuse);
%t2 = vec length(origin,y use);
%t3 = veclength(origin,zuse);
%t4 = veclength(xuse,y use);
%t5 = veclength(z-use,yuse);
%t6 = veclength(xuse,z use);
%xuse
%yuse
%zuse
%acos((tl^2+t2^2-t4^2)/(2*tl *t2))
%acos((t2^2+t3^2-t5A2)/(2*t2*t3))
%acos((t3^2+t 1^24t6A2)/(2*t3*tl))
else
94
randbest.m(cont.):
yuse = -ytrans;
%Now, we want to slide the x use temp vector to the center of the 2rd ccd => slide by
%3.5 degrees
slide = 3.5*(pi/180);
holdi =
point4
hold2 =
hold3 =
hold4 =
point5
ztrans*adjl*tan(slide);
satIc + hold1;
point4-sbv;
veclength(sbv,point4);
adj 1*cos(slide);
sbv + (hold4/hold3)*hold2;
x_use
z_use
hold2/hold3;
(point5-sat I c)/veclength(sat 1c,point5);
=
=
%For checking purposes on orthogonality/length
%tl = vec_length(origin,xuse);
%t2 = vec_length(origin,yuse);
%t3 = vec_length(origin,zuse);
%t4 = veclength(xuse,y use);
%t5 = vec_length(zuse,y use);
%t6 = vec_length(xuse,zuse);
%xuse
%yuse
%zuse
%acos((t l^2+t2^2-t4^2)/(2*tl*t2))
%acos((t2^2+t3A2-t5^2)/(2*t2*t3))
%acos((t3A2+t lA2-t6A2)/(2*t3*tI))
end
%Now, orientation of satellite at this point is xuse, y-use, zuse.
%Need to find timing constraint, iterate for different angles about target in future
%Have picked random orientation, find its comparison value
temppath = [O,x use,yuse,z use,satl (1),satl (1)];
comparetemp = adjfunction(adj matrix,temppath);
if starttime == currenttime
timel = 1;
else
newpos = [xuse;yuse;z use];
timeI = sat timing(cur pos,newpos);
end
compare = comparetemp/time 1;
if compare > overallmax
best-one = [0,0,currenttime,compare,xuse,yuse,zuse,sat 1(1 ),sat 1(1)];
stagemax = best_one;
overallmax = compare;
end
end
end
if countl > 1
%Now, we need to set up the new coordinate axis
95
randbest.m(cont.):
xaxistot = viewable(],:);
%removing the satellite number from set
xaxis = [xaxis tot(2),xaxistot(3),xaxistot(4)];
%we find the length of the slant vector
I = veclength(sat Ic,sbv);
%We now find the range (in distance) of the optical sensor of the sbv
c = l*tan(5.6*(pi/180));
%Find the distance from sbv to satk for xaxis satellite
sbvsat2 = veclength(sbv,xaxis);
%This is the distance from the sbv to the projection of sat2 to the perpendicular
%plane to sbv-satl.
v_satl _satk =
vec length(satIc,xaxis);
vec length(satIc,sbv);
v_satk_sby = vec-length(xaxis,sbv);
alpha = acos((vsatlsbv^2+vsatksbv^2-v_satl_satk^2)/(2*v-satlsbv*vsatksbv));
vsatl _sbv
sbvproj = l*tan(alpha);
sbvxpoint = (P^2 + (sbvproj)^2)^.5;
%Can use this to find the projection point (x,y,z)
xl = sbv(l) + (sbvxpoint/sbvsat2)*(xaxis(l) - sbv(l));
yl = sbv(2) + (sbv xpoint/sbvsat2)*(xaxis(2) - sbv(2));
zl = sbv(3) + (sbv _xpoint/sbvsat2)*(xaxis(3) - sbv(3));
x_temp = [x I,y l,zl];
%Need vector length to be = c??????
x2 =satlc(l) + (c/sbvproj)*(x temp(l) - satlc(l));
y2 = sat l c(2) + (c/sbvproj)*(x temp(2) - sat Ic(2));
z2 = sat Ic(3) + (c/sbvproj)*(x temp(3) - sat I c(3));
point2 = [x2,y2,z2];
point3 = p3(sbv,satlc,point2,c);
%shows that they are orthogonal and
%veclength(sat Ic,point2);
%veclength(sat I c,point3);
%veclength(point2,point3);
c
%vec length(sbv,sat I c)
%vec length(sbv,point3)
%veclength(sat Ic,point3)
%veclength(sbv,sat I c)
%veclength(sbv,point2)
%vec length(satl c,point2)
temp I = size(viewable);
temp2 = temp
l(l);
for n = I:temp2;
%now we need to find the angle from each satellite to the reference
xaxistot = viewable(n,:);
%removing the satellite number from set
xaxis = [xaxistot(2),xaxis-tot(3),xaxis tot(4)];
%we find the length of the slant vector
I = vec_length(satlc,sbv);
%We now find the range (in distance) of the optical sensor of the sbv
c = I*tan(5.6*(pi/1 80));
%Find the distance from sbv to satk for xaxis satellite
sbvsat2 = vec-length(sbv,xaxis);
%This is the distance from the sbv to the projection of sat2 to the perpendicular
96
randbest.m(cont.):
%plane to sbv-satl.
v_sati _satk =veclength(satlc,xaxis);
v_sat Isbv = veclength(sat lc,sbv);
v_satksbv = veclength(xaxis,sbv);
alpha =acos((vsatlsbv^2+vsatksbv^2-v_satsatk^2)/(2*v
sati sbv*v satk_sbv));
sbvproj = l*tan(alpha);
sbv xpoint = (1^2 + (sbvproj)^2)^.5;
%Can use this to find the projection point (x,y,z)
x l = sbv(1) + (sbvxpoint/sbvsat2)*(xaxis(l) - sbv(l));
yl = sbv(2) + (sbv xpoint/sbvsat2)*(xaxis(2) - sbv(2));
zI = sbv(3) + (sbvxpoint/sbv sat2)*(xaxis(3) - sbv(3));
xproj = [xl,yl,zl];
%Use satIc,point2,xtemp
v] I = vec_length(sat Ic,x proj);
v12 = veclength(satlc,point2);
v13 = veclength(xproj,point2);
alpha = acos((vl l^2+vl2^2-vl3^2)/(2*vl l*v12));
if -isreal(alpha)
%Occasionally the innacuracy of the calculation will cause acos(l+). Since this
%is not geometrically possible, we get a complex answer. The magnitude is small
%however, as innacuracy is small. Thus, we take the real part = 0.
alpha = real(alpha);
end;
%Use satlc,point3,x temp
v21 = veclength(sat lc,xproj);
v22 = vec length(satlc,point3);
v23 = veclength(xproj,point3);
alpha2 = acos((v2 I^2+v22^2-v23^2)/(2*v2l *v22));
if alpha2 > (pi/2)
alpha = (2*pi) - alpha;
end
tempsat(count2,:) = [alpha, sat 1c, point2, point3,sat l(1),xaxis tot(1)];
count2 = count2 +
1;
%fprintf('alpha is %6.1Of \n',alpha);
end;
%Using Insertion sort to order tempsat by alpha (only around 25 sat/field max right now)
%Might implement recursive sorting if needed later
%set up initial conditions for sorting algorithm
count3 = 1;
s3 = size(tempsat);
s3a = s3(l);
clear real sat
form = l:s3a;
%set the initial max to be the first element
t-maxhold = tempsat(l,:);
t_max = t_maxhold(1);
a max 1;
97
randbest.m(cont.):
fork= l:s3a;
tI = tempsat(k,:);
if t1(1) > t-max;
t_max= t l (l);
a_max =k;
end;
end;
realsat(count3,:) = tempsat(amax,:);
remem = tempsat(a max,:);
r l = remem(l);
%reinsert result into temp matrix, only negative angle => will not be reconsidered
tempsat(a max,:)= [-rl,satlc,point2, point3,satl(l),xaxistot(l)];
count3 = count3 +
1;
end;
%Now, real sat contains the sorted element list for the particular view.
%We want to find if any are in the same field of view
if (current-time == start time)
use-p = 0;
else
use-p = 1;
end
bestone = within angle(realsat,currenttimesbvusep,curpos,adjmatrix);
compare = best one(1,4);
if compare > overallmax
stage-max = bestone;
overall-max = compare;
end
end;
end;
end;
res = stagemax;
readin.m:
function satdata = readin(a);
%Function to bring in the satellite data from a data file
%sat-data = readin(a) where a is the name if the text file
[a b c d e f g h k I m] = textread(a,'%s %d %f %f%f %f %f%f %f %f%s');
satdata = [b,c,d,e,fg,h,k,l];
satavail.m:
function sats = sat avail(current time,m,sat);
%current time in days, like element set. m = #sat to use
%sat is matrix of element sets to use
%
----------------------------------------------
%returns vector = [length, width]
sl = size(sat);
s2 = sl(l);
if m > s2;
98
satavail.m (cont.):
fprintf('Not sufficient satellites: Viewing all %d \n',s2);
m = s2;
end;
%-------------------------
%sbv element set for use
sbv = [23851, 99.394, 21.704, .000700, 269.649,90.387,1.1410727, 355.2082490, 99];
origin = [0,0,0];
el = sbv;
sbvvec = sat vec(el,current time);
earthsbv = [origin',sbvvec'];
%plot3(earthsbv(1,:),earthsbv(2,:),earthsbv(3,:),'r');
%hold on;
%grid on;
indI
=
1;
for I = :in;
el = sat(l,:);
temp I = satvec(el,currenttime);
temp2 = [origin',templ'];
sbvsat = temp I - sbv_vec;
temp3 = [sbvvec',sbvsat'];
%a is to sbv, b is to sat, c is difference
b = veclength(temp I,origin);
a = veclength(sbvyvec,origin);
c = veclength(sbvsat,origin);
%check to see if earth blocks sby from satellite
inc = earth check(a,b,c);
if inc == 0
%find the sun vector (x,y,z) at current time
sunnow = sunvec(current-time);
sbvsun = sunnow - sbvvec;
temp5 = [sbvvec',sbvsun'];
%check to see if sun will block satellite
inc2 = suncheck(sbvvec,temp l,sunnow);
if inc2 == 0;
sats(ind1,:) = [el(l),tempI];
indl = indl + 1;
end;
end;
end;
sattiming.m:
function res = sattiming(prevstate,new state);
%This script will calculate the timing requirements in sec from one orientation of the sby satellite
%prevstate (3 by 3 matrix) to a new orientation = final state (also 3 by 3 matrix)
holdI = prevstate';
hold2 = hold I *new_state;
t I = trace(hold2);
99
sat timing.m (cont.):
angi = .5*(tl 1);
if angi > I
angl = 1;
end
if angl <-1
angl= -1;
end
ang2 = acos(ang
Itheta =
1);
ang2*57.295779;
if Itheta <0
ltheta = -Itheta;
end
if ltheta > 180
ltheta = 180;
end
if Itheta >= 160
res = .2*ltheta + 209;
elseif itheta >= 140
res = .9125*ltheta + 95;
elseif ltheta >= 110
res = .525*ltheta + 149.25;
elseif Itheta >= 70
res = .825 * Itheta + 116.25;
elseif ltheta >= 50
res = .97625*ltheta + 105.6625;
elseif Itheta >= 30
res = -. 0668*ltheta*ltheta + 6.5664*ltheta - 6.845;
elseif ltheta >= 15
res = I.668466667*ltheta + 79.973;
elseif ltheta >= 10
res = 3.8*ltheta + 48;
else
res = 2.6*ltheta + 60;
end
satvec.m:
function trip = sat vec(el,t);
%function to find the x,y,z coordinates of the satellite given by element set el
%at time t
a
=
el(7)*1000*6378.14;
e = el(4);
ra = e](3)*(2*pi/360);
w = e(5)*(2*pi/360);
inc = el(2)*(2*pi/360);
px = cos(w)*cos(ra) - sin(ra)*sin(w)*cos(inc);
py = cos(w)*sin(ra) + sin(w)*cos(ra)*cos(inc);
pz = sin(w)*sin(inc);
qx = -sin(w)*cos(ra) - cos(w)*sin(ra)*cos(inc);
qy = -sin(w)*sin(ra) + cos(w)*cos(ra)*cos(inc);
qz = cos(w)*sin(inc);
temp = orbit xy(el,t);
xw = temp(l);
100
satvec.m (cont.):
yw = temp(2);
trip(l) = xw*px + yw*qx;
trip(2) = xw*py + yw*qy;
trip(3) = xw*pz + yw*qz;
simL.m:
function res = siml(s,e,m);
%s is start time, e is end time in days, just as element set.
sat = readin('datanew.dat');
%--------------------------------------------
%num l = 2643;
%test satellites are 5,675,2643;
%returns vector = [length, width]
sI = size(sat);
s2
=
s](l);
ifm>s2;
fprintf('Not sufficient satellites: Viewing all %d \n',s2);
m = s2;
end;
%------------------------------
%sbv element set for use
sbv = [23851, 99.394, 21.704, .000700, 269.649,90.387,1.1410727, 355.2082490, 99];
current-time = s;
origin = [0,0,0];
el = sbv;
sbvvec = sat vec(el,current time);
earth_sbv = [origin',sbvvec'];
%plot3(earthsbv(l,:),earthsbv(2,:),earth_sbv(3,:),'r');
%hold on;
%grid on;
while currenttime < e
count = 0;
for = I:m;
el = sat(l,:);
temp I = sat vec(elcurrenttime);
temp2 = [origin',tempi'];
%hold on;
sbv_sat = temp I - sbv vec;
temp3 = [sbv vec',sbv sat'];
%plot3(temp3(1,:),temp3(2,:), temp3(3,:),'y');
%a is to sby, b is to sat, c is difference
b = veclength(templ,origin);
a = veclength(sbvvec,origin);
c = veclength(sbv-sat,origin);
%check to see if earth blocks sbv from satellite
inc = earthcheck(a,b,c);
%find the sun vector (x,y,z) at current time
sun now = sun vec(current time);
101
siml.m (cont.):
sbvsun = sunnow - sbvvec;
temp5 = [sbv_vec',sbv sun'];
%check to see if sun will block satellite
inc2 = sun check(sbvvec,tempI,sunnow);
if inc2 == 0;
if inc == 0;
%plot3(temp3(1,:),temp3(2,:),temp3(3,:));
count = count +
1;
%hold on;
end;
elseif inc2 == 1;
%plot3(temp3(1,:),temp3(2,:),temp3(3,:),'g');
%hold on;
end
%temp4 = [origin',sunnow'];
%plot3(temp4(1,:),temp4(2,:),temp4(3,:),'y');
end;
fprintf('%d satellites viewable at %6.5f\n',count,current time);
current-time = current time + 1;
end;
count
%rotate3d;
%Following includes the earth in the plot
%[x,y,z] = sphere;
%x = x*1000*6378.14;
%y = y*1000*6378.14;
%z = z* 1000*6378. 14;
%surf(x,y,z);
sim2.m:
function res = sim2(s,e,m);
%s is start time, e is end time in days, just as element set.
time 10 = clock;
sat = readin('data new.dat');
clear adjmatrix;
fid = fopen('origresult.dat','wt')
%-----------------------------------------------
%numl = 2643;
%test satellites are 5,675,2643;
%returns vector = [length, width]
si = size(sat);
s2 = sl(l);
if m > s2;
fprintf('Not sufficient satellites: Viewing all %d \n',s2);
m = s2;
end;
fork = l:m;
adjmatrix(k,:) = [sat(k,l),I];
end;
0/--------------------------------
102
sim2.m (cont.):
%sbv element set for use
sbv = [23851, 99.394, 2 1.704, .000700, 269.649,90.387,1.1410727, 355.2082490, 99];
currenttime = s;
origin = [0,0,0];
el
=
sbv;
curpos = 0;
rescount
=
1;
clear resmat;
while currenttime < e
fprintf('current time is %6. 1Of \n',currenttime);
if current time == s
use-time = currenttime
else
use time = current time + .0013888;
end
sbvvec = satvec(el,usetime);
earthsbv = [origin',sbvvec'];
time I = clock;
usethese = sat_avail(use-time,m,sat);
time2 = clock;
time2-time1
%Will replace 0 with current position below
time I = clock;
bestorient = find_best(use thesesbv_veccurrent time,s,cur-pos,adjmatrix);
time2 = clock;
time2-time I
x_pos = [bestorient(1,5), best orient( 1,6),best orient( 1,7)];
ypos = [best orient(1,8), best orient( 1,8),best orient( 1,10)];
z_pos = [best-orient( 1,1 1), bestorient( 1, 12),bestorient( 1,13)];
curpos = [xpos;ypos;zpos];
timer = bestorient(1,3);
if timer ==
1
%timer == 1implies on first round, set skip time to 51.2 sec. = data collection
timer = 51.2/(24*60*60);
else
%convert seconds of rotation into days, after adding 51.2 sec. for data collection
timer = (timer+51.2)/(24*60*60);
end
bl = size(best orient);
b2 = bl(l);
%Need to update the adjustment matrix for successive iterations
%Find adjmatrix with target I number and increment
fork= 1:m
if best orient(1, 14) == adjmatrix(k,l)
adjmatrix(k,2) = adjmatrix(k,2) + 10;
end
end
%Find adjmatrix with each target2 number and increment
for k =
l:b2;
103
sim2.m (cont.):
res mat(res_count,:) = [current_timebest orient(k,:)];
rescount = rescount +
for n
=
1;
1:m
if best orient(k, 15) == adjmatrix(n, I)
adjmatrix(n,2) = adjmatrix(n,2) + 10;
end
end
end;
currenttime = currenttime + timer;
end;
tempi = size(resmat);
r =templ(l);
fork= :r
fprintf(fid,'%6.7f %6.3f %6.3f %6.3f %6.3f %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f %d %d
\n',resmat(k, 1),resmat(k,2),resmat(k,3),resmat(k,4),resmat(k,5),resmat(k,6),resmat(k,7),resmat(k,8),resmat(k,9),res
0),resmat(k, I I ),res mat(k, I 2),resmat(k, I 3),resmat(k,14),res mat(k, I 5),resmat(k, 16));
end
mat(k, I
fclose(fid);
time I I = clock;
time 1I-time 10
suncheck.m:
function res = suncheck(a,b,c);
%function to see if the SBV sat vector is too close to the sun
%a = SBV coordinates (x,y,z), b = Satellite coordinates (x,y,z), c = sun position (from sun vec)
%result of 0 is good, result of 1indicates path is through earth.
%assumes a is greater than earth's radius
alpha-critical = (80/360)*(2*pi);
v_sunsbv
=
v_sunsat =
v_sbvsat
=
vec_length(a,c);
veclength(b,c);
veclength(a,b);
alpha = acos((v_sbv_sat^2+vsunsbvA2-v_sun satA2)/(2*v_sbv_sat*vsunsby));
if alpha > alphacritical;
res = 0;
else
res= 1;
end
sunvec.m:
function res = sun_vec(t);
%t is time of inquisition in days
%accuracy not essential, simply simulates constraint
%149.5*10^6 km, place into meters
a= 149.5*(10A6);
e = (23.439)*(2*pi/360);
%march 20th is the 80th day of the year, 2000
104
sunvec.m (cont.):
alpha = ((t - 80)/365.2422)*(2*pi);
t_1
= a*sin(alpha);
t_2 = -a*cos(alpha);
%transition from ecliptic orbit to celestial or equitorial orbit;
res(l) = a*cos(alpha);
res(2) = a*sin(alpha)*cos(e);
res(3) = a*sin(alpha)*sin(e);
test.m:
function res = test(filen,a,b,numiter);
counter= 1;
%Read in the original matrix of results
[al bl c I di el fl gi hI jI k Il l ml ni p qI rl]= textread(filen,'%f %f%f %f%f %f%f %f%f %f %f%f %f %f%d %d');
tempmat=[al bI cI di el fl gI hI jI kl I ml ni p1 qI rl];
%Find the value of the original path
sI = size(tempmat);
s2 = si(i);
sat = readin('datanew.dat');
clear adj matrix;
s3 = size(sat);
s4 = s3(i);
fork = 1:s4;
adjmatrix(k,:) = [sat(k,I),I];
end;
val=0;
ct = 0;
fork= l:s2;
if ct -= tempmat(k, 15)
for 1 = i:s4
if adj matrix(l, 1) == tempmat(k,15)
val = val + 1/(adjmatrix(1,2));
adj matrix(1,2)= adjmatrix(1,2) + 10;
end
if adj matrix(, 1) == tempmat(k, 16)
val = val + 1/(adj matrix(l,2));
adjmatrix(1,2) = adjmatrix(1,2) + 10;
end
1+1;
=
end
ct = tempmat(k, 15);
else
for I = l:s4
if adjmatrix(i, 1) == tempmat(k, 16)
val = val + 1/(adjmatrix(1,2));
adjmatrix(1,2) = adjmatrix(1,2) + 10;
=
1+1;
end
end
end
end
%Randomly make improvements and recheck value
105
test.m (cont.):
for m = a:b
better = I;
worse =
1;
for v = I:numiter;
clear adjmatrix;
fprintf('Testing position %d, iteration %d.... \n',m,v);
s3 = size(sat);
s4 = s3(l);
fork= 1:s4;
adjmatrix(k,:) = [sat(k,I),l];
end;
line = 1;
count = I;
view = 0;
newmat =
if m= I
while count < m;
newmat(line,:) = tempmat(line,:);
if new_mat(line,l) == view
for r = l:s4;
ifadjmatrix(r, I) == newmat(line,16)
adjmatrix(r,2) = adjmatrix(r,2) + 10;
end
end
else
if newmat(line, 15) == new mat(line, 16)
for r = l:s4;
if adjmatrix(r, 1) == new mat(line, 16)
adjmatrix(r,2) = adjmatrix(r,2) + 10;
end
end
view = newmat(line,I);
else
for r= l:s4;
ifadj matrix(r, I) == new mat(line,15)
adj matrix(r,2) = adjmatrix(r,2) + 10;
end
if adjmatrix(r, I) == new mat(line, 16)
adjmatrix(r,2) = adjmatrix(r,2) + 10;
end
end
view = newmat(line,1);
end
end
if tempmat(line+1,1) ~ view
count = count + 1;
end
line
=
line + 1;
end
end
%sbv element set for use
sbv = [23851, 99.394, 21.704, .000700, 269.649,90.387,1.1410727, 355.2082490, 99];
tim 1= size(newmat);
106
test.m (cont.):
tim2 = tim 1(1);
iftim2 >0
currenttime = temp mat((tim2+ 1), 1);
s = tempmat(tim2, I);
xpos = [newmat(tim2,6), newmat(tim2,7),newmat(tim2,8)];
y_pos = [newmat(tim2,9), newmat(tim2,9),newmat(tim2,1 1)];
z_pos = [newmat(tim2, 12), newmat(tim2,13),newmat(tim2,14)];
curpos = [xpos;ypos;zpos];
else
currenttime = tempmat( 1,1);
s = tempmat(1,1);
curpos = 0;
end
origin = [0,0,0];
if tim2 == 0
usetime = current-time;
else
usetime = currenttime + .00 13888;
end
el = sbv;
sbv-vec = sat-vec(el,usetime);
earth_sby = [origin',sbvvec'];
usethese = satavail(use-time,s4,sat);
if v == I
%current-sat = [tempmat(tim2+l,15)];
currentsat = [0];
end
best-orient = randbest(usethesesbv_veccurrent_time,s,curpos,adj
x_pos = [best orient(1,5), best orient(1,6),best orient(1,7)];
y pos = [bestorient(1,8), best_orient(1,8),best orient(1,10)];
zpos = [best-orient(l1, 11), best-orient( 1, 12),best orient( 1,13)];
current sat = [currentsat;best_orient(1,14)];
cur-pos = [xpos;ypos;zpos];
timer = bestorient(1,3);
matrix,current sat);
if timer == I
%timer == I implies on first round, set skip time to 51.2 sec. = data collection
fprintf('herel');
timer = 5 1.2/(24*60*60)
else
%convert seconds of rotation into days, after adding 51.2 sec. for data collection
fprintf('here2');
timer = (timer+51.2)/(24*60*60)
end
bI = size(best orient);
b2 = bl(l);
%Need to update the adjustment matrix for successive iterations
%Find adj matrix with target I number and increment
for k = l:s4
if best orient(1,14) == adj_matrix(k, 1)
adjmatrix(k,2) = adjmatrx(k,2) + 10;
end
end
%Find adjmatrix with each target2 number and increment
for k = l:b2;
107
test.m (cont.):
new_mat(line,:) = [current_timebest_orient(k,:)];
line
=
line
+
1;
for n = l:s4
if best orient(k, 15) == adjmatrix(n, 1)
adjmatrix(n,2) = adjmatrix(n,2) + 10;
end
end
end;
currenttime = currenttime + timer
%find e = time to stop random improvements
e = currenttime + .02083;
se = size(tempmat);
sel = se(l);
if e > tempmat(seI, l)
e = tempmat(se 1,1);
end
while currenttime < e
fprintf('currenttime of new iteration is %6.10f \n',currenttime);
if current time == s
usetime = current-time;
else
usetime = currenttime + .0013888;
end
sbvvec = satvec(el,usetime);
earthsbv = [origin',sbvvec'];
use_these = sat avail(usetime,s4,sat);
%Will replace 0 with current position below
bestorient = find best(use_thesesbvvec,current-time,s,cur pos,adjmatrix);
x_pos = [best.orient(1,5), best orient(I,6),best orient(1,7)];
y_pos = [best orient(1,8), best orient(1,8),best orient(l,10)];
z_pos = [best orient( 1,l1), best orient(l,1 2),best orient(l ,13)];
cur pos = [xpos;ypos;zpos];
timer = best orient(1,3);
iftimer== I
%timer == 1implies on first round, set skip time to 51.2 sec. = data collection
timer = 51.2/(24*60*60);
else
%convert seconds of rotation into days, after adding 51.2 sec. for data collection
timer = (timer+51.2)/(24*60*60);
end
b 1= size(best orient);
b2 = bl(l);
%Need to update the adjustment matrix for successive iterations
%Find adjmatrix with targetl number and increment
fork = l:s4
if best orient(1,14) == adj-matrix(k,I)
adjmatrix(k,2) = adjmatrix(k,2) + 10;
end
end
%Find adjmatrix with each target2 number and increment
108
test.m (cont.):
1:b2;
for k =
newmat(line,:) = [current timebestorient(k,:)];
line = line + 1;
for n = 1:s4
if best orient(k, 15) == adjmatrix(n, 1)
adj matrix(n,2) = adjmatrix(n,2) + 10;
end
end
end;
current-time = current-time + timer;
end;
sl = size(temp mat);
s2 = sl(l);
fprintf('current time at end of randomization is %6.6f,current time);
for k = l:s2
if tempmat(k, 1) >= (current time-.000001);
newmat(line,:) = temp mat(k,:);
line = line + 1;
end
end
%Find value of new path
s I= size(newmat);
s2 = sl(1);
val2 = 0;
ct=0;
clear adjmatrix;
s3 = size(sat);
s4 = s3(l);
fork = 1:s4;
adjmatrix(k,:) = [sat(k,
end;
l), l];
fork= l:s2;
if ct = new mat(k,15)
for I= l:s4
ifadjmatrix(l,1) == newmat(k,15)
val2 = val2 + 1/(adjmatrix(1,2));
adjmatrix(l,2) = adj matrix(1,2) + 10;
end
if adjmatrix(l,l) == newmat(k,16)
val2 = val2 + 1/(adjmatrix(1,2));
adjmatrix(,2) = adjmatrix(1,2) + 10;
end
=
1+1;
end
ct = new mat(k,15);
else
for 1= l:s4
if adjmatrix(l, 1) == newmat(k,16)
val2 = val2 + 1/(adjmatrix(l,2));
adjmatrix(1,2) = adj_matrix(1,2) + 10;
=
1+1;
end
end
end
109
test.m (cont.):
end
%write results to file
remb = num2str(m);
if val2 < val
p ='newworse';
q = num2str(worse);
worse = worse + 1;
else
p = 'newbetter';
q = num2str(better);
better= better+ 1;
end
title = strcat(p,remb,q,'.txt');
fid = fopen(title,'wt');
sl = size(newmat);
s2
=
sl(1);
fprintf(fid,'Value of %6.7f compared to Original %6.7f \n',val2,val);
chs = size(currentsat);
chsl = chs(l);
for chch = l:chsl;
fprintf(fid,'Checked sat #%d \n',current-sat(chch));
end
for k = l:s2;
fprintf(fid,'%6.7f %6.3f %6.3f %6.3f %6.3f %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f %6.7f%6.7f %6.7f %d %d
mat(k,8),newmat(k,9),
\n',newmat(k, 1),newmat(k,2),newmat(k,3),newmat(k,4),newmat(k,5),newmat(k,6),newmat(k,7),new
newmat(k, I 0),newmat(k, I1 ),newmat(k, I 2),new mat(k, I 3),newmat(k, I4),newmat(k, I 5),newmat(k, 16));
end
fclose(fid);
end
end
veclength.m:
function res = veclength(v,ori);
%Finds the length of a vector in 3-dimensions from an origin that ends on point (x,y,z)
x =v(l);
y = v(2);
z v(3);
xl = ori(1);
yl = ori(2);
z I =ori(3);
res = ((x-xl)^2 + (y-y1)A2 + (z-zl)^2)A.5;
withinangle.m:
function res = withinangle(real_satcurrent_timesbvuse_pos,cur_pos,adjmatrix);
%Given a sorted list of satellite points (as given in findbest)
%we pick the angle that has the most satellites covered (with relative value
%adjusted by entry in adjmatrix) with the least amount of transfer time
110
withinangle.m (cont.):
%from current position
s4 = size(realsat);
s4a = s4(l);
sat-max =
1;
max_array = 0;
global cz;
fork=
1:s4a;
runit = 0;
m = 0;
clear outme;
outme(I,:) = real_sat(k,:);
countit = 2;
angtemp = realsat(k,:);
low-bound = ang temp(l);
ang_t = low_bound + ((l.4/180)*pi);
high_bound = mod(angt,2*pi);
%lf the angle we are using as a lower bound is close to the 2*pi rollover, we
%check the list for angles higher than the current lower bound and then simply
%use the calculated upper bound as normal.
if (low_bound >= (2*pi)-((1.4/180)*pi))
%Only need to check 1to k as they are in sorted order, but just in case of error
%and since the expected size of the array is small, we might want to switch to check
%the whole array
for 1= l:k
tl = realsat(I,:);
tempang = tI(1);
if tempang > low_bound;
outme(countit,:) = realsat(l,:);
countit = countit +
1;
end;
end;
m = s4a;
end;
if m == 0;
if k == 1
run_it = 1;
else
m = k-I;
end;
end;
while runit == 0;
%count backwards for increasing angle
angte = realsat(m,:);
angnow = angte(I);
if angnow < highbound;
outme(countit,:) = realsat(m,:);
countit = countit + 1;
if m==I
runit 1
else
m = m-1;
111
within angle.m (cont.):
end;
else
runit =
end;
1;
end;
o
= size(outme);
o2 = oI(I);
fprintf('Satellites in one view
cz(o2) = cz(o2) + 1;
=
%d \n',o2);
if o2 == 1;
anguse = outme(l);
else
low = outme(l,:);
high I = outme(o2,:);
low2 lowl(I);
high2 = high1(1);
%for border cases, i.e. 6.8 and .002
if low2 > high2
al = (2*pi) - low2;
anguse = mod((low2 + (high2 + al)/2),2*pi);
else
anguse = (high2 + low2)/2;
end
end
vec_temp = outme(I,:);
vec Ix = vec_temp(5) - vectemp(2);
vec l y = vectemp(6) - vec-temp(3);
vec I z = vec_temp(7) - vec temp(4);
vecI = [vec l x,vec l y,vec l z];
vec2x = vec_temp(8) - vec temp(2);
vec2y = vectemp(9) - vectemp(3);
vec2z = vec_temp( 10) - vectemp(4);
vec2 = [vec2x,vec2y,vec2z];
origin = [0,0,0];
%simply used to check continued orthogonality in testing
%al = veclength(vec l,origin);
%a2 = veclength(vec2,origin);
%a3 = veclength(vecl,vec2);
%acos((al ^2+a2^2-a3^2)/(2*al *a2));
xtl = cos(anguse);
xt2 = sin(ang use);
%We now transform the x,y axis by the rotation angle anguse
z_trans = vec I *(xtl) + vec2*(xt2);
y trans = vec1*(-xt2) + vec2*(xtI);
bI = veclength(ztrans,origin);
b2 = veclength(ytrans,origin);
b3 = veclength(ztrans,ytrans);
%scale rotated vectors to unit length
z_trans = z_trans/bI;
y_trans = ytrans/b2;
%more orthogonality checks
%bI = veclength(ztrans,origin)
%b2 = vece ength(y trans,origin)
112
withinangle.m (cont.):
%b3 = veclength(ztrans,ytrans)
%acos((blA2+b2A2-b3^2)/(2*b I *b2))
%Need to decide whether to orient the satellite toward +- y_ trans, given the current position
%ofthe sun.
satic = [vectemp(2),vec temp(3), vectemp(4)];
sun now = sun vec(current time);
satIc to sun = sun-now - sat Ic;
%turn sati c to sun vector into unit length
uniti = veclength(origin,satlcto sun);
stsun = (sati c_tosun/unitI);
%check that the sun-sat] vector is unit length, use for angorient calculation
st_sunI = veclength(origin,st _sun);
%find length of vector between sun-sat I and sat I -sat2 cross = ytrans
p3_sun = vec-length(stsun,ytrans);
%check that yt is unit length, use for angorient
yt = veclength(origin,ytrans);
%For further work: if this angle is pi/2or less, we need to rotate the orientation of the sbv!!!
ang orient = acos((st sunl^2+yt^2-p3_sunA2)/(2*st sunl*yt));
%Get length of sbv -> target I for calculations
x_use temp 1= sat Ic - sbv;
adj I = veclength(origin,xuse-temp1);
if angorient > pi/2
y_use = ytrans;
%Now, we want to slide the xuse temp vector to the center of the 3rd ccd => slide by
%2.1 degrees
slide = 2.l*(pi/180);
holdl = z_trans*adj l *tan(slide);
point4 = satIc + holdI;
hold2 = point4-sbv;
hold3 = vec length(sbv,point4);
hold4 = adj I *cos(slide);
point5 sbv + (hold4/hold3)*hold2;
x use = hold2/hold3;
z_use =(sat 1c-point5)/veclength(sat I c,point5);
%For checking purposes on orthogonality/length
%tI = vec length(origin,xuse);
%t2 = vec length(origin,yuse);
%t3 = vec length(origin,zuse);
%t4 = vec length(xuse,yuse);
%t5 = vec length(zuse,yuse);
%t6 = vec-length(xuse,zuse);
%xuse
%y_use
%zuse
%acos((t I^2+t2^2-t4A2)/(2*t l *t2))
%acos((t2A2+t3A2-t5A2)/(2*t2*t3))
%acos((t3A2+tl A2-t6A2)/(2*t3*tl))
else
113
within angle.m (cont.):
y_use = -ytrans;
%Now, we want to slide the x use temp vector to the center of the 2rd ccd => slide by
%3.5 degrees
slide = 3.5*(pi/l 80);
hold I = z_trans*adj I *tan(slide);
point4 = satIc + holdI;
hold2 = point4-sbv;
hold3 = veclength(sbv,point4);
hold4 =adj I *cos(slide);
point5 = sbv + (hold4/hold3)*hold2;
x_use = hold2/hold3;
z_use
=(point5-sat
I c)/vec_length(sat I c,point5);
%For checking purposes on orthogonality/length
%t I = vec_iength(origin,xuse);
%t2 = vec_length(origin,yuse);
%t3 = vec_length(origin,zuse);
%t4 = vec_length(x_ use,yuse);
%t5 = vec_length(zuse,yuse);
%t6 = vec_length(xuse,zuse);
%xuse
%yuse
%zuse
%acos((tl ^2+t2^2-t4^2)/(2*tI *t2))
%acos((t2^2+t3^2-t5A2)/(2*t2*t3))
%acos((t3A2+tl^2-t6^2)/(2*t3*tI))
end
if usepos == I
%We have a current position, factor in the current position and timing with the
%satellite views
new pos = [xuse;yuse;z use];
time I = sat timing(curpos,newpos);
adj = adjfunction(adjmatrix,outme);
%find satellite-time "density" - with adjustment for repeated satellite viewing
compare = (o2/timel)*adj;
if compare > max-array
%o2 is the size of outme
for q = l:o2
%if outme2 is adjusted, must also adjust the sim2 code for finding current location
%as well as findbest for adjusting timing
outme2(q,:) = [outme(q,1),anguse, time1, compare, xuse, y-use, zuse, outme(q,1 1),outme(q,12)];
end;
out-it = outme2;
max_array = compare;
end;
else
%We do not have a current position, simply find the best grouping
if o2 > maxarray
%o2 is the size of outme
for q = I:o2
%if outme2 is adjusted, must also adjust the sim2 code for finding current location
114
withinangle.m (cont.):
%as well as findbest for adjusted timing
outme2(q,:) = [outme(q, I),anguse, l,o2, xuse, yuse, z-use, outme(q,I 1),outme(q, 12)];
end;
out-it = outme2;
maxarray = o2;
end;
end
end;
%out-it = [ang rotate (for sat2), angle-used, current-time, compare,xuse,yuse,z use,satpivot, sat2]
res = out-it;
115