Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

samporbit.cpp File Reference

#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <celmath/mathlib.h>
#include <celengine/astro.h>
#include <celengine/orbit.h>

Include dependency graph for samporbit.cpp:

Go to the source code of this file.

Functions

static Point3d cubicInterpolate (Point3d &p0, Vec3d &v0, Point3d &p1, Vec3d &v1, double t)
OrbitLoadSampledOrbit (const string &filename)
bool operator< (const Sample &a, const Sample &b)

Variables

static const double MaxSampleInterval = 50.0
static const double MinSampleInterval = 1.0 / 1440.0
static const double SampleThresholdAngle = 2.0


Function Documentation

static Point3d cubicInterpolate Point3d p0,
Vec3d v0,
Point3d p1,
Vec3d v1,
double  t
[static]
 

Definition at line 132 of file samporbit.cpp.

Referenced by SampledOrbit::computePosition().

00135 {
00136     return p0 + (((2.0 * (p0 - p1) + v1 + v0) * (t * t * t)) +
00137                  ((3.0 * (p1 - p0) - 2.0 * v0 - v1) * (t * t)) +
00138                  (v0 * t));
00139 }

Orbit* LoadSampledOrbit const string filename  ) 
 

Definition at line 280 of file samporbit.cpp.

References SampledOrbit::addSample().

Referenced by TrajectoryInfo::load().

00281 {
00282     ifstream in(filename.c_str());
00283     if (!in.good())
00284         return NULL;
00285 
00286     SampledOrbit* orbit = new SampledOrbit();
00287     int nSamples = 0;
00288     while (in.good())
00289     {
00290         double t, x, y, z;
00291         in >> t;
00292         in >> x;
00293         in >> y;
00294         in >> z;
00295 
00296         double jd = t;
00297 
00298         // A bit of a hack . . .  assume that a time >= 1000000 is a Julian
00299         // Day, and anything else is a year + fraction.  This is just here
00300         // for backward compatibility.
00301         if (jd < 1000000.0)
00302         {
00303             int year = (int) t;
00304             double frac = t - year;
00305             // Not quite correct--doesn't account for leap years
00306             jd = (double) astro::Date(year, 1, 1) + 365.0 * frac;
00307         }
00308 
00309         orbit->addSample(jd, x, y, z);
00310         nSamples++;
00311     }
00312 
00313     return orbit;
00314 }

bool operator< const Sample a,
const Sample b
 

Definition at line 40 of file samporbit.cpp.

00041 {
00042     return a.t < b.t;
00043 }


Variable Documentation

const double MaxSampleInterval = 50.0 [static]
 

Definition at line 31 of file samporbit.cpp.

Referenced by SampledOrbit::sample().

const double MinSampleInterval = 1.0 / 1440.0 [static]
 

Definition at line 30 of file samporbit.cpp.

Referenced by SampledOrbit::sample().

const double SampleThresholdAngle = 2.0 [static]
 

Definition at line 32 of file samporbit.cpp.

Referenced by SampledOrbit::sample().


Generated on Sat Jan 14 22:31:11 2006 for Celestia by  doxygen 1.4.1