7
#include "PlanetProperties.h"
10
#include "libannotate/LineSegment.h"
11
#include "libmultiple/libmultiple.h"
12
#include "libplanet/Planet.h"
15
addArc(const double startTime, const double stopTime,
16
const int numTimes, const unsigned char color[3],
18
const int width, const int height,
19
const double Prx, const double Pry, const double Prz,
20
Planet *p, multimap<double, Annotation *> &annotationMap)
22
Options *options = Options::getInstance();
24
const body b = p->Index();
25
const bool isTarget = (b == options->getTarget());
27
const double delTime = (stopTime - startTime) / numTimes;
28
bool firstTime = true;
29
double prevX = 0, prevY = 0, prevZ = 0;
30
for (int i = 0; i <= numTimes; i++)
32
const double jd = startTime + i * delTime;
36
planet.calcHeliocentricEquatorial(false);
37
planet.getPosition(X, Y, Z);
39
view->XYZToPixel(X + Prx, Y + Pry, Z + Prz,
41
X += options->getCenterX();
42
Y += options->getCenterY();
46
double nearX, nearY, nearZ;
47
double farX, farY, farZ;
68
const bool skip = ((prevX < 0 && X < 0)
69
|| (prevY < 0 && Y < 0)
70
|| (prevX >= width && X >= width)
71
|| (prevY >= height && Y >= height)
72
|| (fabs(X) > width*100)
73
|| (fabs(Y) > height*100)
74
|| (fabs(prevX) > width*100)
75
|| (fabs(prevY) > height*100)
76
|| (prevZ < 0 && Z < 0));
78
if (!skip || (i == 1 && isTarget))
80
LineSegment *ls = new LineSegment(color,
83
annotationMap.insert(pair<const double, Annotation*>(farZ, ls));
96
addOrbits(const double jd0, const View *view,
97
const int width, const int height,
98
Planet *p, PlanetProperties *currentProperties,
99
multimap<double, Annotation *> &annotationMap)
101
const double period = p->Period();
102
if (period == 0) return;
104
const double startOrbit = currentProperties->StartOrbit();
105
const double stopOrbit = currentProperties->StopOrbit();
106
const double delOrbit = currentProperties->DelOrbit();
107
const unsigned char *color = currentProperties->OrbitColor();
109
double Prx=0, Pry=0, Prz=0;
110
if (p->Primary() != SUN)
112
Planet primary(jd0, p->Primary());
113
primary.calcHeliocentricEquatorial();
114
primary.getPosition(Prx, Pry, Prz);
117
const double startTime = jd0 + startOrbit * period;
118
const double stopTime = jd0 + stopOrbit * period;
120
const int numTimes = (int) (180/delOrbit + 0.5);
122
addArc(startTime, jd0, numTimes, color, view, width, height,
123
Prx, Pry, Prz, p, annotationMap);
124
addArc(jd0, stopTime, numTimes, color, view, width, height,
125
Prx, Pry, Prz, p, annotationMap);