USGS

Isis 3.0 Developer's Reference (API)

Home

SpiceRotation.h

Go to the documentation of this file.
00001 #ifndef SpiceRotation_h
00002 #define SpiceRotation_h
00003 
00025 #include <string>
00026 #include <vector>
00027 
00028 #include <naif/SpiceUsr.h>
00029 #include <naif/SpiceZfc.h>
00030 #include <naif/SpiceZmc.h>
00031 
00032 #include "Table.h"
00033 #include "Quaternion.h"
00034 #include "PolynomialUnivariate.h"
00035 
00036 #define J2000Code    1
00037 
00038 namespace Isis {
00175   class SpiceRotation {
00176     public:
00178       SpiceRotation(int frameCode);
00179       /*      SpiceRotation( int NaifCode );
00180       We would like to call refchg instead to avoid the strings.  Currently Naif does
00181       not have refchg_c, but only the f2c'd refchg.c.*/
00182       SpiceRotation(int frameCode, int targetCode);
00183       SpiceRotation(const SpiceRotation &rotToCopy);
00184 
00186       virtual ~SpiceRotation() { }
00187 
00189       void SetFrame(int frameCode) {
00190         p_constantFrames[0] = frameCode;
00191       };
00192       int Frame() {
00193         return p_constantFrames[0];
00194       };
00195 
00196       void SetTimeBias(double timeBias);
00201       enum Source { Spice,                  
00202                     Nadir,                  
00203                     Memcache,               
00204                     PolyFunction,           
00205                     PolyFunctionOverSpice}; 
00206                                             //   polynomial
00207 
00208       enum PartialType {WRT_RightAscension, WRT_Declination, WRT_Twist};
00209 
00210       enum DownsizeStatus {Yes, Done, No};
00211       enum NaifFrameType { INERTL = 1, PCK = INERTL + 1, CK = PCK + 1, TK = CK + 1, DYN = TK + 1};
00212 
00213       void SetEphemerisTime(double et);
00214 
00216       double EphemerisTime() const {
00217         return p_et;
00218       };
00219 
00220       std::vector<double> GetCenterAngles();
00221       
00222       std::vector<double> Matrix();
00223       std::vector<double> AngularVelocity() {
00224         return p_av;
00225       };
00226       std::vector<double> &ConstantMatrix() {
00227         return p_TC;
00228       };
00229       std::vector<double> &TimeBasedMatrix() {
00230         return p_CJ;
00231       };
00232 
00233       std::vector<double> J2000Vector(const std::vector<double>& rVec);
00234 
00235       std::vector<double> ReferenceVector(const std::vector<double>& jVec);
00236 
00237       std::vector<double> EvaluatePolyFunction();
00239       void MinimizeCache(DownsizeStatus status) {
00240         p_minimizeCache = status;
00241       };
00242 
00243       void LoadCache(double startTime, double endTime, int size);
00244 
00245       void LoadCache(double time);
00246 
00247       void LoadCache(Table &table);
00248 
00249       Table LineCache(const QString &tableName);
00250 
00251       void ReloadCache();
00252 
00253       Table Cache(const QString &tableName);
00254       void CacheLabel(Table &table);
00255 
00256       void LoadTimeCache();
00257 
00258       std::vector<double> Angles(int axis3, int axis2, int axis1);
00259 
00261       bool IsCached() const {
00262         return (p_cache.size() > 0);
00263       };
00264 
00265       void SetPolynomial(const Source type=PolyFunction);
00266 
00267       void SetPolynomial(const std::vector<double>& abcAng1,
00268                          const std::vector<double>& abcAng2,
00269                          const std::vector<double>& abcAng3,
00270                          const Source type = PolyFunction);
00271 
00272       void GetPolynomial(std::vector<double>& abcAng1,
00273                          std::vector<double>& abcAng2,
00274                          std::vector<double>& abcAng3);
00275 
00277       void SetPolynomialDegree(int degree);
00278 
00280       Source GetSource() {
00281         return p_source;
00282       };
00283 
00285       void SetSource(Source source) {
00286         p_source = source;
00287         return;
00288       };
00289 
00290       void ComputeBaseTime();
00291 
00293       double GetBaseTime() {
00294         return p_baseTime;
00295       };
00296 
00298       double GetTimeScale() {
00299         return p_timeScale;
00300       };
00301 
00302       void SetOverrideBaseTime(double baseTime, double timeScale);
00303 
00304       double DPolynomial(const int coeffIndex);
00305 
00306       std::vector<double> ToReferencePartial(std::vector<double>& lookJ,
00307                                              PartialType partialVar, int coeffIndex);
00308       double WrapAngle(double compareAngle, double angle);
00309       void SetAxes(int axis1, int axis2, int axis3);
00310       std::vector<double> GetFullCacheTime();
00311       void FrameTrace(double et);
00312 
00314       std::vector<int>  ConstantFrameChain() {
00315         return p_constantFrames;
00316       };
00317 
00319       std::vector<int>  TimeFrameChain() {
00320         return p_timeFrames;
00321       };
00322 
00323       void InitConstantRotation(double et);
00324       std::vector<double> ConstantRotation();
00325       std::vector<double> TimeBasedRotation();
00326       void DCJdt(std::vector<double> &dRJ);
00327 
00329       bool HasAngularVelocity() {
00330         return p_hasAngularVelocity;
00331       };
00332 
00333       void ComputeAv();
00334       std::vector<double> Extrapolate(double timeEt);
00335 
00336 
00337     protected:
00338       void SetFullCacheParameters(double startTime, double endTime, int cacheSize);
00339       std::vector<double> p_cacheTime;  
00340       std::vector<std::vector<double> > p_cache;      
00341 
00342       //    J2000 to 1st constant frame (CJ) or
00343       //    coefficients of polynomial
00344       //    fit to rotation angles
00345       int p_degree;                     
00346       int p_axis1;                      
00347       int p_axis2;                      
00348       int p_axis3;                      
00349       void SetEphemerisTimeMemcache();
00350       void SetEphemerisTimeNadir();
00351       void SetEphemerisTimeSpice();
00352       void SetEphemerisTimePolyFunction();
00353       void SetEphemerisTimePolyFunctionOverSpice();
00354 
00355     private:
00356       std::vector<int> p_constantFrames;  
00357       //    The first entry will always be the target frame code
00358       std::vector<int> p_timeFrames;      
00359       //    The last entry will always be 1 (J2000 code)
00360       double p_timeBias;                  
00361 
00362       double p_et;                        
00363       Quaternion p_quaternion;            
00364       //   rotation at et
00365 
00366       bool p_matrixSet;                   
00367 
00368       Source p_source;                    
00369       int p_axisP;                        
00370       //   vector for defining a nadir rotation
00371       int p_axisV;                        
00372       //   vector for defining a nadir rotation
00373       int p_targetCode;                   
00374 
00375       double p_baseTime;                  
00376       double p_timeScale;                 
00377       bool p_degreeApplied;               
00378       //    of degree p_degree has been created and
00379       //    used to fill the cache
00380       std::vector<double> p_coefficients[3];  
00381       bool p_noOverride;                  
00382       double p_overrideBaseTime;          
00383       double p_overrideTimeScale;         
00384       DownsizeStatus p_minimizeCache;     
00385       double p_fullCacheStartTime;        
00386       double p_fullCacheEndTime;          
00387       int p_fullCacheSize;                
00388       std::vector<double> p_TC;           
00389       //    time-based rotations in frame chain from J2000 to target)
00390       //    to the target frame
00391       std::vector<double> p_CJ;           
00392       //    after all the time-based rotations in frame chain from
00393       std::vector<std::vector<double> > p_cacheAv;
00395       std::vector<double> p_av;           
00396       bool p_hasAngularVelocity;          
00397       std::vector<double> StateTJ();      
00398   };
00399 };
00400 
00401 #endif
00402