~ubuntu-branches/ubuntu/trusty/xplanet/trusty

« back to all changes in this revision

Viewing changes to .pc/orbit-step-bug/src/libmultiple/addOrbits.cpp

  • Committer: Package Import Robot
  • Author(s): Steve McIntyre
  • Date: 2014-01-30 18:54:10 UTC
  • mfrom: (4.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20140130185410-o2u51emh707gbevv
Tags: 1.3.0-1
* New maintainer
* Move to new upstream version 1.3.0. (Closes: #678464)
  + Upstream highlights:
    - add "outlined" keyword to marker files
    - update JPL ephemeris code for 64 bit machines
    - add bump_shade config file parameter
    - add opacity keyword for markers
    - implement Rayleigh scattering
  + Remove old Debian patches now obsoleted:
    - possible-buffer-overflow (included upstream)
    - orbit-step-bug (included upstream)
    - gcc44-includes (included upstream)
    - hyphen-used-as-minus-sign (included upstream)
    - tsc-aspect-ratio (included upstream)
  + Update (and include!) FreeMonoBold
* Update libtiff build-deps (Closes: #736052)
* Update libpng build-deps (Closes: #662568)
* Update Standards-Version to 3.9.5
* Update to debhelper 9 to enable hardening build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <cmath>
2
 
#include <cstring>
3
 
#include <map>
4
 
using namespace std;
5
 
 
6
 
#include "body.h"
7
 
#include "Options.h"
8
 
#include "PlanetProperties.h"
9
 
#include "View.h"
10
 
 
11
 
#include "libannotate/LineSegment.h"
12
 
#include "libmultiple/libmultiple.h"
13
 
#include "libplanet/Planet.h"
14
 
 
15
 
static void
16
 
addArc(const double startTime, const double stopTime, 
17
 
       const int numTimes, const unsigned char color[3],
18
 
       const int thickness, const View *view, 
19
 
       const int width, const int height, 
20
 
       const double Prx, const double Pry, const double Prz,
21
 
       Planet *p, multimap<double, Annotation *> &annotationMap)
22
 
{
23
 
    Options *options = Options::getInstance();
24
 
 
25
 
    const body b = p->Index();
26
 
    const double delTime = (stopTime - startTime) / numTimes;
27
 
 
28
 
    for (int i = 0; i <= numTimes; i++)
29
 
    {
30
 
        bool skipThisArc = false;
31
 
        double oldX, oldY, oldZ;
32
 
        double newX, newY, newZ;
33
 
 
34
 
        for (int j = 0; j < 2; j ++)
35
 
        {
36
 
            const double jd = startTime + (i + j) * delTime;
37
 
 
38
 
            double X, Y, Z;
39
 
            Planet planet(jd, b);
40
 
            planet.calcHeliocentricEquatorial(false);
41
 
            planet.getPosition(X, Y, Z);
42
 
            
43
 
            view->XYZToPixel(X + Prx, Y + Pry, Z + Prz,
44
 
                             X, Y, Z);
45
 
            X += options->CenterX();
46
 
            Y += options->CenterY();
47
 
            if (X < -width || X > 2*width 
48
 
                || Y < -height || Y > 2*height
49
 
                || Z < 0)
50
 
            {
51
 
                skipThisArc = true;
52
 
                break;
53
 
            }
54
 
 
55
 
            if (j == 0)
56
 
            {
57
 
                oldX = X;
58
 
                oldY = Y;
59
 
                oldZ = Z;
60
 
            }
61
 
            else
62
 
            {
63
 
                newX = X;
64
 
                newY = Y;
65
 
                newZ = Z;
66
 
            }
67
 
        }
68
 
        
69
 
        if (skipThisArc) continue;
70
 
 
71
 
        LineSegment *ls = new LineSegment(color, thickness, 
72
 
                                          oldX, oldY,
73
 
                                          newX, newY);
74
 
 
75
 
        double midZ = 0.5 * (oldZ + newZ);
76
 
        annotationMap.insert(pair<const double, Annotation*>(midZ, ls));
77
 
    }
78
 
}
79
 
 
80
 
void
81
 
addOrbits(const double jd0, const View *view, 
82
 
          const int width, const int height, 
83
 
          Planet *p,  PlanetProperties *currentProperties, 
84
 
          multimap<double, Annotation *> &annotationMap)
85
 
{
86
 
    const double period = p->Period();
87
 
    if (period == 0) return;
88
 
 
89
 
    const double startOrbit = currentProperties->StartOrbit();
90
 
    const double stopOrbit = currentProperties->StopOrbit();
91
 
    const double delOrbit = currentProperties->DelOrbit();
92
 
    const unsigned char *color = currentProperties->OrbitColor();
93
 
    const int thickness = currentProperties->ArcThickness();
94
 
 
95
 
    double Prx=0, Pry=0, Prz=0;
96
 
    if (p->Primary() != SUN)
97
 
    {
98
 
        Planet primary(jd0, p->Primary());
99
 
        primary.calcHeliocentricEquatorial();
100
 
        primary.getPosition(Prx, Pry, Prz);
101
 
    }
102
 
 
103
 
    const double startTime = jd0 + startOrbit * period;
104
 
    const double stopTime = jd0 + stopOrbit * period;
105
 
 
106
 
    const int numTimes = (int) (180/delOrbit + 0.5);
107
 
 
108
 
    addArc(startTime, jd0, numTimes, color, thickness, view, width, height, 
109
 
           Prx, Pry, Prz, p, annotationMap);
110
 
    addArc(jd0, stopTime, numTimes, color, thickness, view, width, height, 
111
 
           Prx, Pry, Prz, p, annotationMap);
112
 
}