sgp4/libsgp4/Eci.h

152 lines
3.2 KiB
C
Raw Normal View History

2013-04-01 10:33:34 +00:00
/*
* Copyright 2013 Daniel Warner <contact@danrw.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2011-12-16 23:38:28 +00:00
#ifndef ECI_H_
#define ECI_H_
#include "CoordGeodetic.h"
#include "Vector.h"
2012-10-11 18:52:51 +00:00
#include "DateTime.h"
2011-12-16 23:38:28 +00:00
2012-10-11 18:52:51 +00:00
/**
* @brief Stores an Earth-centered inertial position for a particular time.
2012-10-11 18:52:51 +00:00
*/
2011-12-16 23:38:28 +00:00
class Eci
{
public:
2012-10-11 18:52:51 +00:00
/**
* @param[in] dt the date to be used for this position
* @param[in] latitude the latitude in degrees
* @param[in] longitude the longitude in degrees
* @param[in] altitude the altitude in kilometers
2011-12-16 23:38:28 +00:00
*/
2012-10-11 18:52:51 +00:00
Eci(const DateTime& dt,
const double latitude,
const double longitude,
const double altitude)
2011-12-16 23:38:28 +00:00
{
2012-10-11 18:52:51 +00:00
ToEci(dt, CoordGeodetic(latitude, longitude, altitude));
2011-12-16 23:38:28 +00:00
}
2012-10-11 18:52:51 +00:00
/**
* @param[in] dt the date to be used for this position
* @param[in] geo the position
*/
Eci(const DateTime& dt, const CoordGeodetic& geo)
2011-12-16 23:38:28 +00:00
{
2012-10-11 18:52:51 +00:00
ToEci(dt, geo);
2011-12-16 23:38:28 +00:00
}
2012-10-11 18:52:51 +00:00
/**
* @param[in] dt the date to be used for this position
* @param[in] position
*/
Eci(const DateTime &dt, const Vector &position)
: m_dt(dt),
m_position(position)
2011-12-16 23:38:28 +00:00
{
}
2012-10-11 18:52:51 +00:00
/**
* @param[in] dt the date to be used for this position
* @param[in] position the position
* @param[in] velocity the velocity
*/
Eci(const DateTime &dt, const Vector &position, const Vector &velocity)
: m_dt(dt),
m_position(position),
m_velocity(velocity)
2011-12-16 23:38:28 +00:00
{
}
2012-10-11 18:52:51 +00:00
/**
* Destructor
*/
2011-12-16 23:38:28 +00:00
virtual ~Eci()
{
}
2012-10-11 18:52:51 +00:00
/**
* Equality operator
* @param dt the date to compare
* @returns true if the object matches
*/
bool operator==(const DateTime& dt) const
{
return m_dt == dt;
}
/**
* Inequality operator
* @param dt the date to compare
* @returns true if the object doesn't match
*/
bool operator!=(const DateTime& dt) const
{
return m_dt != dt;
}
/**
* Update this object with a new date and geodetic position
* @param dt new date
* @param geo new geodetic position
*/
void Update(const DateTime& dt, const CoordGeodetic& geo)
{
ToEci(dt, geo);
}
/**
* @returns the position
*/
Vector Position() const
2011-12-16 23:38:28 +00:00
{
2012-10-11 18:52:51 +00:00
return m_position;
2011-12-16 23:38:28 +00:00
}
2012-10-11 18:52:51 +00:00
/**
* @returns the velocity
*/
Vector Velocity() const
2011-12-16 23:38:28 +00:00
{
2012-10-11 18:52:51 +00:00
return m_velocity;
2011-12-16 23:38:28 +00:00
}
2012-10-11 18:52:51 +00:00
/**
* @returns the date
*/
DateTime GetDateTime() const
2011-12-16 23:38:28 +00:00
{
2012-10-11 18:52:51 +00:00
return m_dt;
2011-12-16 23:38:28 +00:00
}
2012-10-11 18:52:51 +00:00
/**
* @returns the position in geodetic form
*/
2011-12-16 23:38:28 +00:00
CoordGeodetic ToGeodetic() const;
private:
2012-10-11 18:52:51 +00:00
void ToEci(const DateTime& dt, const CoordGeodetic& geo);
DateTime m_dt;
Vector m_position;
Vector m_velocity;
2011-12-16 23:38:28 +00:00
};
#endif