sgp4/libsgp4/CoordTopocentric.h

132 lines
3.1 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.
*/
#ifndef COORDTOPOCENTRIC_H_
#define COORDTOPOCENTRIC_H_
2011-12-16 23:38:28 +00:00
#include "Util.h"
2011-12-16 23:38:28 +00:00
2012-10-11 18:52:51 +00:00
#include <string>
2011-12-16 23:38:28 +00:00
#include <sstream>
#include <iomanip>
2022-11-13 11:06:08 +00:00
namespace libsgp4
{
2012-10-11 18:52:51 +00:00
/**
* @brief Stores a topocentric location (azimuth, elevation, range and range
* rate).
*
* Azimuth and elevation are stored in radians. Range in kilometres. Range
* rate in kilometres/second.
2012-10-11 18:52:51 +00:00
*/
2017-01-07 12:44:19 +00:00
struct CoordTopocentric
2011-12-16 23:38:28 +00:00
{
public:
2012-10-11 18:52:51 +00:00
/**
* Default constructor
*/
CoordTopocentric()
: azimuth(0.0)
, elevation(0.0)
, range(0.0)
, range_rate(0.0)
2011-12-16 23:38:28 +00:00
{
}
2012-10-11 18:52:51 +00:00
/**
* Constructor
* @param[in] az azimuth in radians
* @param[in] el elevation in radians
* @param[in] rnge range in kilometers
* @param[in] rnge_rate range rate in kilometers per second
2012-10-11 18:52:51 +00:00
*/
CoordTopocentric(
double az,
double el,
double rnge,
double rnge_rate)
: azimuth(az)
, elevation(el)
, range(rnge)
, range_rate(rnge_rate)
2011-12-16 23:38:28 +00:00
{
}
2012-10-11 18:52:51 +00:00
/**
* Copy constructor
* @param[in] topo object to copy from
*/
CoordTopocentric(const CoordTopocentric& topo)
2011-12-16 23:38:28 +00:00
{
2012-10-11 18:52:51 +00:00
azimuth = topo.azimuth;
elevation = topo.elevation;
range = topo.range;
range_rate = topo.range_rate;
2011-12-16 23:38:28 +00:00
}
2012-10-11 18:52:51 +00:00
/**
* Assignment operator
* @param[in] topo object to copy from
*/
CoordTopocentric& operator=(const CoordTopocentric& topo)
2011-12-16 23:38:28 +00:00
{
2012-10-11 18:52:51 +00:00
if (this != &topo)
{
azimuth = topo.azimuth;
elevation = topo.elevation;
range = topo.range;
range_rate = topo.range_rate;
2011-12-16 23:38:28 +00:00
}
return *this;
}
2012-10-11 18:52:51 +00:00
/**
* Dump this object to a string
* @returns string
*/
2011-12-16 23:38:28 +00:00
std::string ToString() const
{
std::stringstream ss;
2012-10-11 18:52:51 +00:00
ss << std::right << std::fixed << std::setprecision(3);
ss << "Az: " << std::setw(8) << Util::RadiansToDegrees(azimuth);
ss << ", El: " << std::setw(8) << Util::RadiansToDegrees(elevation);
ss << ", Rng: " << std::setw(10) << range;
ss << ", Rng Rt: " << std::setw(7) << range_rate;
2011-12-16 23:38:28 +00:00
return ss.str();
}
2012-10-11 18:52:51 +00:00
/** azimuth in radians */
2011-12-16 23:38:28 +00:00
double azimuth;
2012-10-11 18:52:51 +00:00
/** elevations in radians */
2011-12-16 23:38:28 +00:00
double elevation;
2012-10-11 18:52:51 +00:00
/** range in kilometers */
2011-12-16 23:38:28 +00:00
double range;
2012-10-11 18:52:51 +00:00
/** range rate in kilometers per second */
2011-12-16 23:38:28 +00:00
double range_rate;
};
inline std::ostream& operator<<(std::ostream& strm, const CoordTopocentric& t)
2011-12-16 23:38:28 +00:00
{
return strm << t.ToString();
}
2022-11-13 11:06:08 +00:00
} // namespace libsgp4
2011-12-16 23:38:28 +00:00
#endif