mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
Finished cleaning the SpiceManager
This commit is contained in:
@@ -242,7 +242,7 @@ TEST_F(SpiceManagerTest, getTargetPosition){
|
||||
|
||||
glm::dvec3 targetPosition;
|
||||
double lightTime = 0.0;
|
||||
bool found = openspace::SpiceManager::ref().getTargetPosition("EARTH", et, "J2000", "LT+S", "CASSINI",
|
||||
bool found = openspace::SpiceManager::ref().getTargetPosition("EARTH", "CASSINI", "J2000", "LT+S", et,
|
||||
targetPosition, lightTime);
|
||||
ASSERT_TRUE(found);
|
||||
EXPECT_DOUBLE_EQ(pos[0], targetPosition[0]) << "Position not found or differs from expected return";
|
||||
@@ -265,7 +265,7 @@ TEST_F(SpiceManagerTest, getTargetState){
|
||||
glm::dvec3 targetPosition;
|
||||
glm::dvec3 targetVelocity;
|
||||
double lightTime = 0.0;
|
||||
bool found = openspace::SpiceManager::ref().getTargetState("EARTH", et, "J2000", "LT+S", "CASSINI",
|
||||
bool found = openspace::SpiceManager::ref().getTargetState("EARTH", "CASSINI", "J2000", "LT+S", et,
|
||||
targetPosition, targetVelocity, lightTime);
|
||||
ASSERT_TRUE(found);
|
||||
//x,y,z
|
||||
@@ -292,7 +292,7 @@ TEST_F(SpiceManagerTest, getStateTransformMatrix){
|
||||
glm::dvec3 position(state[0], state[1], state[2]);
|
||||
glm::dvec3 velocity(state[3], state[4], state[5]);
|
||||
|
||||
openspace::transformMatrix stateMatrix(6);
|
||||
openspace::SpiceManager::TransformMatrix stateMatrix;
|
||||
bool found = openspace::SpiceManager::ref().getStateTransformMatrix("J2000",
|
||||
"IAU_PHOEBE",
|
||||
et,
|
||||
@@ -301,12 +301,12 @@ TEST_F(SpiceManagerTest, getStateTransformMatrix){
|
||||
//check for matrix consistency
|
||||
for (int i = 0; i < 6; i++){
|
||||
for (int j = 0; j < 6; j++){
|
||||
EXPECT_DOUBLE_EQ(referenceMatrix[i][j], stateMatrix(i, j)) << "State-matrix not set or has wrong values";
|
||||
EXPECT_DOUBLE_EQ(referenceMatrix[i][j], stateMatrix[i * 6 + j]) << "State-matrix not set or has wrong values";
|
||||
}
|
||||
}
|
||||
mxvg_c(referenceMatrix, state, 6, 6, state_t);
|
||||
|
||||
stateMatrix.transform(position, velocity);
|
||||
openspace::SpiceManager::ref().applyTransformationMatrix(position, velocity, stateMatrix);
|
||||
|
||||
for (int i = 0; i < 3; i++){
|
||||
EXPECT_DOUBLE_EQ(position[i], state_t[i]) << "Position vector differs from its reference";
|
||||
@@ -326,7 +326,7 @@ TEST_F(SpiceManagerTest, getPositionTransformMatrix){
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
pxform_c("CASSINI_HGA", "J2000", et, referenceMatrix);
|
||||
|
||||
openspace::transformMatrix positionMatrix(3);
|
||||
glm::dmat3 positionMatrix;
|
||||
glm::dvec3 position(state[0], state[1], state[2]);
|
||||
bool found = openspace::SpiceManager::ref().getPositionTransformMatrix("CASSINI_HGA",
|
||||
"J2000",
|
||||
@@ -336,13 +336,13 @@ TEST_F(SpiceManagerTest, getPositionTransformMatrix){
|
||||
//check for matrix consistency
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
EXPECT_DOUBLE_EQ(referenceMatrix[i][j], positionMatrix(i, j)) << "Position-matrix not set or has wrong values";
|
||||
EXPECT_DOUBLE_EQ(referenceMatrix[i][j], positionMatrix[i][j]) << "Position-matrix not set or has wrong values";
|
||||
}
|
||||
}
|
||||
//transform reference position into new frame
|
||||
mxvg_c(referenceMatrix, state, 3, 3, state_t);
|
||||
|
||||
positionMatrix.transform(position);
|
||||
position = positionMatrix * position;
|
||||
//check transformed values match
|
||||
for (int i = 0; i < 3; i++){
|
||||
EXPECT_DOUBLE_EQ(position[i], state_t[i]) << "Position vector differs from its reference";
|
||||
@@ -356,32 +356,31 @@ TEST_F(SpiceManagerTest, getFieldOfView){
|
||||
int n;
|
||||
int cassini_ID;
|
||||
double et;
|
||||
double boresight[3];
|
||||
glm::dvec3 boresight;
|
||||
double bounds_ref[5][3];
|
||||
char shape_ref[TYPLEN];
|
||||
char name_ref[FILLEN];
|
||||
double boresightVec[3];
|
||||
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
SpiceBoolean found;
|
||||
bodn2c_c("CASSINI_ISS_NAC", &cassini_ID, &found);
|
||||
ASSERT_TRUE(found == SPICETRUE) << "Cannot locate ID for Cassini";
|
||||
|
||||
getfov_c(cassini_ID, 5, TYPLEN, TYPLEN, shape_ref, name_ref, boresight, &n, bounds_ref);
|
||||
getfov_c(cassini_ID, 5, TYPLEN, TYPLEN, shape_ref, name_ref, boresightVec, &n, bounds_ref);
|
||||
|
||||
std::string shape, name;
|
||||
shape.resize(32);
|
||||
name.resize(32);
|
||||
std::vector<glm::dvec3> bounds;
|
||||
int nrReturned;
|
||||
found = openspace::SpiceManager::ref().getFieldOfView("CASSINI_ISS_NAC",
|
||||
shape,
|
||||
name,
|
||||
boresight,
|
||||
bounds,
|
||||
nrReturned);
|
||||
bounds);
|
||||
ASSERT_TRUE(found == SPICETRUE);
|
||||
//check vectors have correct values
|
||||
for (int i = 0; i < nrReturned; i++){
|
||||
for (int i = 0; i < bounds.size(); i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
EXPECT_DOUBLE_EQ(bounds_ref[i][j], bounds[i][j]) << "One or more Field of View Boundary vectors \
|
||||
differ from expected output";
|
||||
@@ -389,80 +388,6 @@ TEST_F(SpiceManagerTest, getFieldOfView){
|
||||
}
|
||||
unload_c(META.c_str());
|
||||
}
|
||||
// Try converting rectangular coordinates to latitudal
|
||||
TEST_F(SpiceManagerTest, rectangularToLatitudal){
|
||||
loadMetaKernel();
|
||||
|
||||
char frame[FILLEN], shape[FILLEN];
|
||||
double lat, lon;
|
||||
double bounds[4][3], bsight[3],
|
||||
obspos[3], point_ref[3];
|
||||
double dist, et, radius_ref, trgepc;
|
||||
int n, naifId;
|
||||
bool found;
|
||||
SpiceBoolean foundSpice;
|
||||
|
||||
// First, find an intersection point to convert to rectangular coordinates
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
bodn2c_c("CASSINI_ISS_NAC", &naifId, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
getfov_c(naifId, 4, FILLEN, FILLEN, shape, frame, bsight, &n, bounds);
|
||||
srfxpt_c("Ellipsoid", "PHOEBE", et, "LT+S", "CASSINI", frame, bsight,
|
||||
point_ref, &dist, &trgepc, obspos, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
|
||||
reclat_c(point_ref, &radius_ref, &lon, &lat);
|
||||
glm::dvec3 point(point_ref[0], point_ref[1], point_ref[2]);
|
||||
double radius, longitude, latitude;
|
||||
found = openspace::SpiceManager::ref().rectangularToLatitudal(point, radius, longitude, latitude);
|
||||
|
||||
ASSERT_TRUE(found);
|
||||
ASSERT_NEAR(radius, radius_ref, abs_error) << "radius is not set / has incorrect values";
|
||||
ASSERT_NEAR(longitude, lon, abs_error) << "longitude is not set / has incorrect values";
|
||||
ASSERT_NEAR(latitude, lat, abs_error) << "latitude is not set / has incorrect values";
|
||||
unload_c(META.c_str());
|
||||
}
|
||||
// Try converting latitudinal coordinates to rectangular
|
||||
TEST_F(SpiceManagerTest, latitudinalToRectangular){
|
||||
loadMetaKernel();
|
||||
|
||||
char frame[FILLEN], shape[FILLEN];
|
||||
double lat, lon;
|
||||
double bounds[4][3], bsight[3],
|
||||
obspos[3], point_ref[3];
|
||||
double dist, et, radius_ref, trgepc;
|
||||
int n, naifId;
|
||||
SpiceBoolean foundSpice;
|
||||
|
||||
// First, find an intersection point to convert to latitudinal coordinates //
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
bodn2c_c("CASSINI_ISS_NAC", &naifId, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
getfov_c(naifId, 4, FILLEN, FILLEN, shape, frame, bsight, &n, bounds);
|
||||
foundSpice = SPICEFALSE;
|
||||
srfxpt_c("Ellipsoid", "PHOEBE", et, "LT+S", "CASSINI", frame, bsight,
|
||||
point_ref, &dist, &trgepc, obspos, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
|
||||
reclat_c(point_ref, &radius_ref, &lon, &lat);
|
||||
|
||||
lat *= rpd_c();
|
||||
lon *= rpd_c();
|
||||
|
||||
double lat_ref = lat;
|
||||
double lon_ref = lon;
|
||||
|
||||
double rectangular_ref[3];
|
||||
latrec_c(radius_ref, lon, lat, rectangular_ref);
|
||||
|
||||
glm::dvec3 coordinates;
|
||||
bool found = openspace::SpiceManager::ref().latidudinalToRectangular(radius_ref, lon, lat, coordinates);
|
||||
|
||||
ASSERT_TRUE(found);
|
||||
ASSERT_NEAR(lon_ref, lon, abs_error) << "longitude is not set / has incorrect values";
|
||||
ASSERT_NEAR(lat_ref, lat, abs_error) << "latitude is not set / has incorrect values";
|
||||
unload_c(META.c_str());
|
||||
}
|
||||
// Try to convert planetocentric coordinates to rectangular
|
||||
TEST_F(SpiceManagerTest, planetocentricToRectangular){
|
||||
loadPCKKernel();
|
||||
@@ -506,9 +431,9 @@ TEST_F(SpiceManagerTest, getSubObserverPoint){
|
||||
subpnt_c(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subObserverPoint_ref, &targetEt_ref, vectorToSurfacePoint_ref);
|
||||
|
||||
bool found = openspace::SpiceManager::ref().getSubObserverPoint(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subObserverPoint,
|
||||
targetEt, vectorToSurfacePoint);
|
||||
bool found = openspace::SpiceManager::ref().getSubObserverPoint(
|
||||
"phoebe", "earth", method[i], "iau_phoebe", "lt+s", et, subObserverPoint,
|
||||
targetEt, vectorToSurfacePoint);
|
||||
ASSERT_TRUE(found);
|
||||
EXPECT_EQ(targetEt_ref, targetEt);
|
||||
for (int i = 0; i < 3; i++){
|
||||
@@ -521,34 +446,34 @@ TEST_F(SpiceManagerTest, getSubObserverPoint){
|
||||
unload_c(META.c_str());
|
||||
}
|
||||
// Try getting sub-solar point
|
||||
TEST_F(SpiceManagerTest, getSubSolarPoint){
|
||||
loadMetaKernel();
|
||||
|
||||
double et, targetEt_ref, targetEt;
|
||||
double subSolarPoint_ref[3];
|
||||
double vectorToSurfacePoint_ref[3];
|
||||
static SpiceChar * method[2] = { "Intercept: ellipsoid", "Near point: ellipsoid" };
|
||||
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
|
||||
glm::dvec3 subSolarPoint;
|
||||
glm::dvec3 vectorToSurfacePoint;
|
||||
|
||||
for (int i = 0; i < 2; i++){
|
||||
subslr_c(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subSolarPoint_ref, &targetEt_ref, vectorToSurfacePoint_ref);
|
||||
|
||||
bool found = openspace::SpiceManager::ref().getSubSolarPoint(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subSolarPoint,
|
||||
targetEt, vectorToSurfacePoint);
|
||||
ASSERT_TRUE(found);
|
||||
EXPECT_EQ(targetEt_ref, targetEt);
|
||||
for (int i = 0; i < 3; i++){
|
||||
EXPECT_EQ(subSolarPoint_ref[i], subSolarPoint[i])
|
||||
<< "Sub-solar vector differs from its reference";
|
||||
EXPECT_EQ(vectorToSurfacePoint_ref[i], vectorToSurfacePoint[i])
|
||||
<< "Observer to surface point vector differs from its reference";
|
||||
}
|
||||
}
|
||||
unload_c(META.c_str());
|
||||
}
|
||||
//TEST_F(SpiceManagerTest, getSubSolarPoint){
|
||||
// loadMetaKernel();
|
||||
//
|
||||
// double et, targetEt_ref, targetEt;
|
||||
// double subSolarPoint_ref[3];
|
||||
// double vectorToSurfacePoint_ref[3];
|
||||
// static SpiceChar * method[2] = { "Intercept: ellipsoid", "Near point: ellipsoid" };
|
||||
//
|
||||
// str2et_c("2004 jun 11 19:32:00", &et);
|
||||
//
|
||||
// glm::dvec3 subSolarPoint;
|
||||
// glm::dvec3 vectorToSurfacePoint;
|
||||
//
|
||||
// for (int i = 0; i < 2; i++){
|
||||
// subslr_c(method[i], "phoebe", et, "iau_phoebe",
|
||||
// "lt+s", "earth", subSolarPoint_ref, &targetEt_ref, vectorToSurfacePoint_ref);
|
||||
//
|
||||
// bool found = openspace::SpiceManager::ref().getSubSolarPoint(method[i], "phoebe", et, "iau_phoebe",
|
||||
// "lt+s", "earth", subSolarPoint,
|
||||
// targetEt, vectorToSurfacePoint);
|
||||
// ASSERT_TRUE(found);
|
||||
// EXPECT_EQ(targetEt_ref, targetEt);
|
||||
// for (int i = 0; i < 3; i++){
|
||||
// EXPECT_EQ(subSolarPoint_ref[i], subSolarPoint[i])
|
||||
// << "Sub-solar vector differs from its reference";
|
||||
// EXPECT_EQ(vectorToSurfacePoint_ref[i], vectorToSurfacePoint[i])
|
||||
// << "Observer to surface point vector differs from its reference";
|
||||
// }
|
||||
// }
|
||||
// unload_c(META.c_str());
|
||||
//}
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class transformMatrix;
|
||||
|
||||
class SpiceManager {
|
||||
public:
|
||||
typedef std::array<double, 36> TransformMatrix;
|
||||
|
||||
/**
|
||||
* Initializer that initializes the static member.
|
||||
*/
|
||||
@@ -133,8 +133,10 @@ public:
|
||||
* the method <code>bodvrd_c</code> and stored in <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged.
|
||||
* \param body The name of the body whose value should be retrieved
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param body The name of the body whose value should be retrieved or the NAIF ID of
|
||||
* this body
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved value
|
||||
* \return <code>true</code> if the <code>body</code> named a valid body,
|
||||
@@ -143,26 +145,6 @@ public:
|
||||
*/
|
||||
bool getValue(const std::string& body, const std::string& value, double& v) const;
|
||||
|
||||
/**
|
||||
* Retrieves a single <code>value</code> for a certain body with a NAIF ID of
|
||||
* <code>id</code>. This method succeeds iff <code>id</code> is the ID of a valid
|
||||
* body, <code>value</code> is a value associated with the body, and the value
|
||||
* consists of only a single <code>double</code> value. If all conditions are true,
|
||||
* the value is retrieved using the method <code>bodvrd_c</code> and stored in
|
||||
* <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param id The NAIF ID of the body whose information should be retrieved
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved value
|
||||
* \return <code>true</code> if the <code>body</code> named a valid body,
|
||||
* <code>value</code> is a valid item for the <code>body</code> and the retrieved
|
||||
* value is only a single value. <code>false</code> otherwise
|
||||
*/
|
||||
bool getValue(int id, const std::string& value, double& v) const;
|
||||
|
||||
/**
|
||||
* Retrieves a <code>value</code> with three components for a certain
|
||||
* <code>body</code>. This method succeeds iff <code>body</code> is the name of a
|
||||
@@ -171,8 +153,10 @@ public:
|
||||
* is retrieved using the method <code>bodvrd_c</code> and stored in <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged.
|
||||
* \param body The name of the body whose value should be retrieved
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param body The name of the body whose value should be retrieved or the NAIF ID of
|
||||
* the body
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved values
|
||||
* \return <code>true</code> if the <code>body</code> named a valid body,
|
||||
@@ -181,25 +165,6 @@ public:
|
||||
*/
|
||||
bool getValue(const std::string& body, const std::string& value, glm::dvec3& v) const;
|
||||
|
||||
/**
|
||||
* Retrieves a <code>value</code> with three components for a certain body with a
|
||||
* NAIF ID of <code>id</code>. This method succeeds <code>id</code> is the ID of a
|
||||
* valid body, <code>value</code> is a value associated with the body, and the value
|
||||
* consists of three <code>double</code> values. If all conditions are true, the value
|
||||
* is retrieved using the method <code>bodvrd_c</code> and stored in <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param id The NAIF ID of the body whose information should be retrieved
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved values
|
||||
* \return <code>true</code> if the <code>body</code> named a valid body,
|
||||
* <code>value</code> is a valid item for the <code>body</code> and the retrieved
|
||||
* value is only a single value. <code>false</code> otherwise
|
||||
*/
|
||||
bool getValue(int id, const std::string& value, glm::dvec3& v) const;
|
||||
|
||||
/**
|
||||
* Retrieves a <code>value</code> with four components for a certain
|
||||
* <code>body</code>. This method succeeds iff <code>body</code> is the name of a
|
||||
@@ -208,8 +173,10 @@ public:
|
||||
* is retrieved using the method <code>bodvrd_c</code> and stored in <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged.
|
||||
* \param body The name of the body whose value should be retrieved
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param body The name of the body whose value should be retrieved or the NAIF ID of
|
||||
* the body
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved values
|
||||
* \return <code>true</code> if the <code>body</code> named a valid body,
|
||||
@@ -218,25 +185,6 @@ public:
|
||||
*/
|
||||
bool getValue(const std::string& body, const std::string& value, glm::dvec4& v) const;
|
||||
|
||||
/**
|
||||
* Retrieves a <code>value</code> with four components for a certain body with a
|
||||
* NAIF ID of <code>id</code>. This method succeeds <code>id</code> is the ID of a
|
||||
* valid body, <code>value</code> is a value associated with the body, and the value
|
||||
* consists of four <code>double</code> values. If all conditions are true, the value
|
||||
* is retrieved using the method <code>bodvrd_c</code> and stored in <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param id The NAIF ID of the body whose information should be retrieved
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved values
|
||||
* \return <code>true</code> if the <code>body</code> named a valid body,
|
||||
* <code>value</code> is a valid item for the <code>body</code> and the retrieved
|
||||
* value is only a single value. <code>false</code> otherwise
|
||||
*/
|
||||
bool getValue(int id, const std::string& value, glm::dvec4& v) const;
|
||||
|
||||
/**
|
||||
* Retrieves a <code>value</code> with an arbitrary number of components for a certain
|
||||
* <code>body</code>. This method succeeds <code>body</code> is a valid body,
|
||||
@@ -247,8 +195,10 @@ public:
|
||||
* the method <code>bodvrd_c</code> and stored in <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged.
|
||||
* \param body The body whose information should be retrieved
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param body The body whose information should be retrieved or the NAIF ID of that
|
||||
* body
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved values. The size of this vector
|
||||
* determines how many values will be retrieved
|
||||
@@ -259,28 +209,6 @@ public:
|
||||
bool getValue(const std::string& body, const std::string& value,
|
||||
std::vector<double>& v) const;
|
||||
|
||||
/**
|
||||
* Retrieves a <code>value</code> with an arbitrary number of components for a certain
|
||||
* body with a NAIF ID of <code>id</code>. This method succeeds <code>id</code> is the
|
||||
* ID of a valid body, <code>value</code> is a value associated with the body, and the
|
||||
* value consists of a number of <code>double</code> values. The requested number is
|
||||
* equal to the <code>size</code> of the passed vector <code>v</code> which means that
|
||||
* this vector has to be preallocated. If all conditions are true, the value is
|
||||
* retrieved using the method <code>bodvrd_c</code> and stored in <code>v</code>
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html. If one of
|
||||
* the conditions is false an error is logged and the value <code>v</code> is
|
||||
* unchanged. For a description on NAIF IDs, see
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html.
|
||||
* \param id The NAIF ID of the body whose information should be retrieved
|
||||
* \param value The value of that should be retrieved, this value is case-sensitive
|
||||
* \param v The destination for the retrieved values. The size of this vector
|
||||
* determines how many values will be retrieved
|
||||
* \return <code>true</code> if the <code>body</code> named a valid body,
|
||||
* <code>value</code> is a valid item for the <code>body</code> and the retrieved
|
||||
* value is only a single value. <code>false</code> otherwise
|
||||
*/
|
||||
bool getValue(int id, const std::string& value, std::vector<double>& v) const;
|
||||
|
||||
/**
|
||||
* Converts the <code>epochString</code> representing a date to a double precision
|
||||
* value representing the <code>ephemerisTime</code>; that is the number of TDB
|
||||
@@ -315,193 +243,219 @@ public:
|
||||
const std::string& format = "YYYY MON DDTHR:MN:SC.### ::RND");
|
||||
|
||||
/**
|
||||
* Return the position of a target body relative to an observing
|
||||
* body, optionally corrected for light time (planetary aberration)
|
||||
* and stellar aberration.
|
||||
* For further details, please refer to 'spkpos_c' in SPICE Docummentation
|
||||
*
|
||||
* \param target Target body name.
|
||||
* \param ephemeris Observer epoch.
|
||||
* \param referenceFrame Reference frame of output position vector.
|
||||
* \param aberrationCorrection Aberration correction flag.
|
||||
* \param observer Observing body name.
|
||||
* \param targetPosition Position of target.
|
||||
* \param lightTime One way light time between observer and target.
|
||||
* \return Whether the function succeeded or not
|
||||
* Returns the <code>position</code> of a <code>target</code> body relative to an
|
||||
* <code>observer</code> in a specific <code>referenceFrame</code>, optionally
|
||||
* corrected for light time (planetary aberration) and stellar aberration
|
||||
* (<code>aberrationCorrection</code>). For further details, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkpos_c.html. For more
|
||||
* information on NAIF IDs, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html
|
||||
* \param target The target body name or the target body's NAIF ID
|
||||
* \param observer The observing body name or the observing body's NAIF ID
|
||||
* \param referenceFrame The reference frame of the output position vector
|
||||
* \param aberrationCorrection The aberration correction flag out of the list of
|
||||
* values (<code>NONE</code>, <code>LT</code>, <code>LT+S</code>, <code>CN</code>,
|
||||
* <code>CN+S</code> for the reception case or <code>XLT</code>, <code>XLT+S</code>,
|
||||
* <code>XCN</code>, or <code>XCN+S</code> for the transmission case.
|
||||
* \param ephemerisTime The time at which the position is to be queried
|
||||
* \param position The output containing the position of the target; if the method
|
||||
* fails, the target position is unchanged
|
||||
* \param lightTime If the <code>aberrationCorrection</code> is different from
|
||||
* <code>NONE</code>, this variable will contain the one-way light time between the
|
||||
* observer and the target. If the method fails, the lightTime is unchanged
|
||||
* \return <code>true</code> if the function was successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
bool getTargetPosition(const std::string& target,
|
||||
double ephemerisTime,
|
||||
const std::string& observer,
|
||||
const std::string& referenceFrame,
|
||||
const std::string& aberrationCorrection,
|
||||
const std::string& observer,
|
||||
glm::dvec3& targetPosition,
|
||||
double ephemerisTime,
|
||||
glm::dvec3& position,
|
||||
double& lightTime) const;
|
||||
|
||||
|
||||
/**
|
||||
* Return the state (position and velocity) of a target body
|
||||
* relative to an observing body, optionally corrected for light
|
||||
* time (planetary aberration) and stellar aberration.
|
||||
* For further details, please refer to 'spkezr_c' in SPICE Docummentation
|
||||
*
|
||||
* \param target Target body name.
|
||||
* \param ephemerisTime Observer epoch.
|
||||
* \param referenceFrame Reference frame of output state vector.
|
||||
* \param aberrationCorrection Aberration correction flag.
|
||||
* \param observer Observing body name.
|
||||
* \param targetPosition Position of target.
|
||||
* \param targetVelocity Velocity of target.
|
||||
* \param lightTime One way light time between observer and target.
|
||||
* \return Whether the function succeeded or not
|
||||
* Returns the state vector (<code>position</code> and <code>velocity</code>) of a
|
||||
* <code>target</code> body relative to an <code>observer</code> in a specific
|
||||
* <code>referenceFrame</code>, optionally corrected for light time (planetary
|
||||
* aberration) and stellar aberration (<code>aberrationCorrection</code>). For further
|
||||
* details, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkezr_c.html. For more
|
||||
* information on NAIF IDs, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html
|
||||
* \param target The target body name or the target body's NAIF ID
|
||||
* \param observer The observing body name or the observing body's NAIF ID
|
||||
* \param referenceFrame The reference frame of the output position vector
|
||||
* \param aberrationCorrection The aberration correction flag out of the list of
|
||||
* values (<code>NONE</code>, <code>LT</code>, <code>LT+S</code>, <code>CN</code>,
|
||||
* <code>CN+S</code> for the reception case or <code>XLT</code>, <code>XLT+S</code>,
|
||||
* <code>XCN</code>, or <code>XCN+S</code> for the transmission case.
|
||||
* \param ephemerisTime The time at which the position is to be queried
|
||||
* \param position The output containing the position of the target; if the method
|
||||
* fails, the position is unchanged
|
||||
* \param velocity The output containing the velocity of the target; if the method
|
||||
* fails, the velocity is unchanged
|
||||
* \param lightTime If the <code>aberrationCorrection</code> is different from
|
||||
* <code>NONE</code>, this variable will contain the one-way light time between the
|
||||
* observer and the target.If the method fails, the lightTime is unchanged
|
||||
* \return <code>true</code> if the function was successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
bool getTargetState(const std::string& target,
|
||||
double ephemerisTime,
|
||||
const std::string& observer,
|
||||
const std::string& referenceFrame,
|
||||
const std::string& aberrationCorrection,
|
||||
const std::string& observer,
|
||||
glm::dvec3& targetPosition,
|
||||
glm::dvec3& targetVelocity,
|
||||
double ephemerisTime,
|
||||
glm::dvec3& position,
|
||||
glm::dvec3& velocity,
|
||||
double& lightTime) const;
|
||||
|
||||
// Computing Transformations Between Frames (FK) -------------------------------------- //
|
||||
|
||||
/**
|
||||
* Return the state transformation matrix from one frame to
|
||||
* another at a specified epoch.
|
||||
* For further details, please refer to 'sxform_c' in SPICE Docummentation
|
||||
*
|
||||
* \param fromFrame Name of the frame to transform from.
|
||||
* \param toFrame Name of the frame to transform to.
|
||||
* \param et Epoch of the rotation matrix.
|
||||
* \param posTransMat A rotation matrix.
|
||||
* \return Whether the function succeeded or not
|
||||
* Returns the state transformation matrix used to convert from one frame to another
|
||||
* at a specified <code>ephemerisTime</code>. For further details, please refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/sxform_c.html.
|
||||
* \param sourceFrame The name of the source reference frame
|
||||
* \param destinationFrame The name of the destination reference frame
|
||||
* \param ephemerisTime The time at which the transformation matrix is to be queried
|
||||
* \param transformationMatrix The output containing the TransformMatrix containing
|
||||
* the transformation matrix that defines the transformation from the
|
||||
* <code>sourceFrame</code> to the <code>destinationFrame</code>. If the method fails
|
||||
* the <code>transformationMatrix</code> is unchanged
|
||||
* \return <code>true</code> if the function was successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
bool getStateTransformMatrix(const std::string& fromFrame,
|
||||
const std::string& toFrame,
|
||||
bool getStateTransformMatrix(const std::string& sourceFrame,
|
||||
const std::string& destinationFrame,
|
||||
double ephemerisTime,
|
||||
transformMatrix& stateMatrix) const;
|
||||
TransformMatrix& transformationMatrix) const;
|
||||
|
||||
/**
|
||||
* Return the matrix that transforms position vectors from one
|
||||
* specified frame to another at a specified epoch.
|
||||
* For further details, please refer to 'pxform_c' in SPICE Docummentation
|
||||
*
|
||||
* \param fromFrame Name of the frame to transform from.
|
||||
* \param toFrame Name of the frame to transform to.
|
||||
* \param et Epoch of the state transformation matrix.
|
||||
* \param stateTransMat A state transformation matrix.
|
||||
* \return Whether the function succeeded or not
|
||||
* Returns the matrix that transforms position vectors from one reference frame to
|
||||
* another at a specified <code>ephemerisTime</code>. For further details, please refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pxform_c.html.
|
||||
* \param sourceFrame The name of the source reference frame
|
||||
* \param destinationFrame The name of the destination reference frame
|
||||
* \param ephemerisTime The time at which the transformation matrix is to be queried
|
||||
* \param transformationMatrix The output containing the transformation matrix that
|
||||
* defines the transformation from the <code>sourceFrame</code> to the
|
||||
* <code>destinationFrame</code>. If the method fails the
|
||||
* <code>transformationMatrix</code> is unchanged
|
||||
* \return <code>true</code> if the function was successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
bool getPositionTransformMatrix(const std::string& fromFrame,
|
||||
const std::string& toFrame,
|
||||
double ephemerisTime,
|
||||
transformMatrix& positionMatrix) const;
|
||||
|
||||
|
||||
void getPositionTransformMatrixGLM(const std::string& fromFrame,
|
||||
const std::string& toFrame,
|
||||
bool getPositionTransformMatrix(const std::string& sourceFrame,
|
||||
const std::string& destinationFrame,
|
||||
double ephemerisTime,
|
||||
glm::dmat3& positionMatrix) const;
|
||||
|
||||
// Retrieving Instrument Parameters (IK) ------------------------------------------ //
|
||||
glm::dmat3& transformationMatrix) const;
|
||||
|
||||
/**
|
||||
* This routine returns the field-of-view (FOV) parameters for a
|
||||
* specified instrument.
|
||||
* For further details, please refer to 'getfov_c' in SPICE Docummentation
|
||||
*
|
||||
* \param naifInstrumentId NAIF ID of an instrument.
|
||||
* \param instrumentFovShape Instrument Field Of View shape.
|
||||
* \param nameOfFrame Name of fram in which FOV vectors are defines.
|
||||
* \param boresightVector Boresight vector.
|
||||
* \param numberOfBoundaryVectors Number of boundary vectors returned.
|
||||
* \param bounds Field Of View boundary vectors
|
||||
* \param room Maximum number of vectors that can be returned.
|
||||
* \return Whether the function succeeded or not
|
||||
* Applies the <code>transformationMatrix</code> retrieved from
|
||||
* getStateTransformMatrix to the <code>position</code> and <code>velocity</code>. The
|
||||
* <code>position</code> and <code>velocity</code> parameters are used as input and
|
||||
* output.
|
||||
* \param position The position that should be transformed. The transformed position
|
||||
* will be stored back in this parameter
|
||||
* \param velocity The velocity that should be transformed. The transformed velocity
|
||||
* will be stored back in this parameter
|
||||
* \param transformationMatrix The 6x6 transformation matrix retrieved from
|
||||
* getStateTransformMatrix that is used to transform the <code>position</code> and
|
||||
* <code>velocity</code> vectors
|
||||
*/
|
||||
bool getFieldOfView(const std::string& naifInstrumentId,
|
||||
void applyTransformationMatrix(glm::dvec3& position,
|
||||
glm::dvec3& velocity,
|
||||
const TransformMatrix& transformationMatrix);
|
||||
|
||||
/**
|
||||
* This routine returns the field-of-view (FOV) parameters for a specified
|
||||
* <code>instrument</code>. For further details, please refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getfov_c.html.
|
||||
* \param instrument The name of the instrument for which the FOV is to be retrieved
|
||||
* \param fovShape The output containing the rough shape of the returned FOV. If the
|
||||
* method fails, this value remains unchanged
|
||||
* \param frameName The output containing the name of the frame in which the FOV
|
||||
* <code>bounds</code> are computed. If the method fails, this value remains unchanged
|
||||
* \param boresightVector The output containing the boresight, that is the vector for
|
||||
* the center direction of the FOV. If the method fails, this value remains unchanged
|
||||
* \param bounds The output containing the values defining the bounds of the FOV as
|
||||
* explained by http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getfov_c.html.
|
||||
* If the method fails, this value remains unchanged
|
||||
* \return <code>true</code> if the function was successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
bool getFieldOfView(const std::string& instrument,
|
||||
std::string& fovShape,
|
||||
std::string& frameName,
|
||||
double boresightVector[],
|
||||
std::vector<glm::dvec3>& bounds,
|
||||
int& nrReturned) const;
|
||||
|
||||
// Computing Planetocentric, Planetodetic, and Planetographic Coordinates ---------- //
|
||||
|
||||
/**
|
||||
* Convert from rectangular coordinates to latitudinal coordinates.
|
||||
* For further details, please refer to 'reclat_c ' in SPICE Docummentation
|
||||
*
|
||||
* \param coordinates Rectangular coordinates of a point, 3-vectors
|
||||
* \param radius Distance of the point from the origin.
|
||||
* \param longitude Longitude of the point in radians. The range is [-pi, pi].
|
||||
* \param latitude Latitude of the point in radians. The range is [-pi/2, pi/2].
|
||||
* \return Whether the function succeeded or not
|
||||
*/
|
||||
bool rectangularToLatitudal(const glm::dvec3 coordinates,
|
||||
double& radius,
|
||||
double& longitude,
|
||||
double& latitude) const;
|
||||
/**
|
||||
* Convert from latitudinal coordinates to rectangular coordinates.
|
||||
* For further details, please refer to 'latrec_c ' in SPICE Docummentation
|
||||
*
|
||||
* \param radius Distance of a point from the origin.
|
||||
* \param longitude Longitude of point in radians.
|
||||
* \param longitude Latitude of point in radians.
|
||||
* \param latitude Rectangular coordinates of the point.
|
||||
* \return Whether the function succeeded or not
|
||||
*/
|
||||
bool latidudinalToRectangular(double radius,
|
||||
double& longitude,
|
||||
double& latitude,
|
||||
glm::dvec3& coordinates) const;
|
||||
|
||||
/**
|
||||
* Convert planetocentric latitude and longitude of a surface
|
||||
* point on a specified body to rectangular coordinates.
|
||||
* For further details, please refer to 'srfrec_c ' in SPICE Docummentation
|
||||
*
|
||||
* \param naif_id NAIF integer code of an extended body.
|
||||
* \param longitude Longitude of point in radians.
|
||||
* \param latitude Latitude of point in radians.
|
||||
* \param coordinates Rectangular coordinates of the point.
|
||||
* \return Whether the function succeeded or not
|
||||
*/
|
||||
bool planetocentricToRectangular(const std::string& naifName,
|
||||
double& longitude,
|
||||
double& latitude,
|
||||
glm::dvec3& coordinates) const;
|
||||
|
||||
// Computing Sub - observer and Sub - solar Points --------------------------------- //
|
||||
glm::dvec3& boresightVector,
|
||||
std::vector<glm::dvec3>& bounds) const;
|
||||
|
||||
/**
|
||||
* Compute the rectangular coordinates of the sub-observer point on
|
||||
* a target body at a specified epoch, optionally corrected for
|
||||
* light time and stellar aberration.
|
||||
* For further details, please refer to 'subpnt_c ' in SPICE Docummentation
|
||||
*
|
||||
* \param computationMethod Computation method.
|
||||
* \param target Name of target body.
|
||||
* \param ephemeris Epoch in ephemeris seconds past J2000 TDB.
|
||||
* \param bodyFixedFrame Body-fixed, body-centered target body frame.
|
||||
* \param aberrationCorrection Aberration correction.
|
||||
* \param observer Name of observing body.
|
||||
* \param subObserverPoint Sub-observer point on the target body.
|
||||
* \param targetEpoch Sub-observer point epoch.
|
||||
* \param observerToSubObserverVec Vector from observer to sub-observer point.
|
||||
* \return Whether the function succeeded or not
|
||||
* Converts planeto-centric <code>latitude</code> and <code>longitude</code> of a
|
||||
* surface point on a specified <code>body</code> to rectangular
|
||||
* <code>coordinates</code>. For further details, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/srfrec_c.html.
|
||||
* \param body The body on which the <code>longitude</code> and <code>latitude</code>
|
||||
* are defined. This body needs to have a defined radius for this function to work
|
||||
* \param longitude The longitude of the point on the <code>body</code> in radians
|
||||
* \param latitude The latitude of the point on the <code>body</code> in radians
|
||||
* \param coordinates The output containing the rectangular coordinates of the point
|
||||
* defined by <code>longitude</code> and <code>latitude</code> on the
|
||||
* <code>body</code>. If the method fails, the coordinate are unchanged
|
||||
* \return <code>true</code> if the function was successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
bool getSubObserverPoint(std::string computationMethod,
|
||||
std::string target,
|
||||
double ephemeris,
|
||||
bool planetocentricToRectangular(const std::string& body, double longitude,
|
||||
double latitude, glm::dvec3& coordinates) const;
|
||||
|
||||
/**
|
||||
* Compute the rectangular coordinates of the sub-observer point of an
|
||||
* <code>observer</code> on a target <code>body</code> at a specified
|
||||
* <code>ephemerisTime</code>, optionally corrected for light time and stellar
|
||||
* aberration. For further details, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/subpnt_c.html.
|
||||
* Example: If the sub-observer point on Mars for MRO is requested, the
|
||||
* <code>target</code> would be <code>Mars</code> and the <code>observer</code> would
|
||||
* be <code>MRO</code>.
|
||||
* \param target The name of the target body on which the sub-observer point lies
|
||||
* \param observer The name of the ephemeris object whose sub-observer point should be
|
||||
* retrieved
|
||||
* \param computationMethod The computation method used for the sub-observer point.
|
||||
* Must be one of <code>Near point: ellipsoid</code> or
|
||||
* <code>Intercept: ellipsoid</code> and it determines the interpretation of the
|
||||
* results; see http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/subpnt_c.html
|
||||
* for detailed description on the computation methods
|
||||
* \param bodyFixedFrame The body-fixed, body-centered frame belonging to the
|
||||
* <code>target</code>
|
||||
* \param aberrationCorrection The aberration correction flag out of the list of
|
||||
* values (<code>NONE</code>, <code>LT</code>, <code>LT+S</code>, <code>CN</code>,
|
||||
* <code>CN+S</code> for the reception case or <code>XLT</code>, <code>XLT+S</code>,
|
||||
* <code>XCN</code>, or <code>XCN+S</code> for the transmission case.
|
||||
* \param ephemerisTime The ephemeris time for which the sub-observer point should be
|
||||
* retrieved
|
||||
* \param subObserverPoint The output containing the observer's sub-observer point on
|
||||
* the target body. If the method fails, the value remains unchanged
|
||||
* \param targetEphemerisTime The output containing the target's ephemeris time
|
||||
* accounting for the aberration, if an <code>aberrationCorrection</code> value
|
||||
* different from <code>NONE</code> is chosen. If the method fails, the value remains
|
||||
* unchanged
|
||||
* \param vectorToSurfacePoint The output containing the vector from the observer to
|
||||
* the, potentially aberration corrected, sub-observer point. If the method fails the
|
||||
* value remains unchanged
|
||||
* \return <code>true</code> if the function was successful, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
bool getSubObserverPoint(std::string target,
|
||||
std::string observer,
|
||||
std::string computationMethod,
|
||||
std::string bodyFixedFrame,
|
||||
std::string aberrationCorrection,
|
||||
std::string observer,
|
||||
double ephemerisTime,
|
||||
glm::dvec3& subObserverPoint,
|
||||
double& targetEpoch,
|
||||
double& targetEphemerisTime,
|
||||
glm::dvec3& vectorToSurfacePoint) const;
|
||||
|
||||
/**
|
||||
* Compute the rectangular coordinates of the sub-observer point on
|
||||
* Computes the rectangular coordinates of the sub-solar point on
|
||||
* a target body at a specified epoch, optionally corrected for
|
||||
* light time and stellar aberration.
|
||||
* For further details, please refer to 'subslr_c ' in SPICE Docummentation
|
||||
@@ -517,15 +471,16 @@ public:
|
||||
* \param observerToSubObserverVec Vector from observer to sub-observer point.
|
||||
* \return Whether the function succeeded or not
|
||||
*/
|
||||
bool getSubSolarPoint(std::string computationMethod,
|
||||
std::string target,
|
||||
double ephemeris,
|
||||
std::string bodyFixedFrame,
|
||||
std::string aberrationCorrection,
|
||||
std::string observer,
|
||||
glm::dvec3& subSolarPoint,
|
||||
double& targetEpoch,
|
||||
glm::dvec3& vectorToSurfacePoint) const;
|
||||
//bool getSubSolarPoint(std::string target,
|
||||
// std::string computationMethod,
|
||||
//
|
||||
// double ephemeris,
|
||||
// std::string bodyFixedFrame,
|
||||
// std::string aberrationCorrection,
|
||||
//
|
||||
// glm::dvec3& subSolarPoint,
|
||||
// double& targetEpoch,
|
||||
// glm::dvec3& vectorToSurfacePoint) const;
|
||||
private:
|
||||
struct KernelInformation {
|
||||
std::string path;
|
||||
@@ -534,6 +489,8 @@ private:
|
||||
|
||||
SpiceManager() = default;
|
||||
SpiceManager(const SpiceManager& c) = delete;
|
||||
SpiceManager& operator=(const SpiceManager& r) = delete;
|
||||
SpiceManager(SpiceManager&& r) = delete;
|
||||
|
||||
std::vector<KernelInformation> _loadedKernels;
|
||||
static unsigned int _lastAssignedKernel;
|
||||
@@ -541,99 +498,6 @@ private:
|
||||
static SpiceManager* _manager;
|
||||
};
|
||||
|
||||
/**
|
||||
* SpiceManager helper class, a storage container used to
|
||||
* transform state vectors from one reference frame to another.
|
||||
* The client creates an instance of <code>transformMatrix</code>
|
||||
* and after its been passed to either <code>getStateTransformMatrix</code>
|
||||
* or <code>getPositionTransformMatrix</code> the instantiated object
|
||||
* can transform position and velocity to any specified reference frame.
|
||||
*
|
||||
* Client-side example:
|
||||
* openspace::transformMatrix stateMatrix(6);
|
||||
* openspace::SpiceManager::ref().getStateTransformMatrix("J2000",
|
||||
* "IAU_PHOEBE",
|
||||
* et,
|
||||
* stateMatrix);
|
||||
* stateMatrix.transform(position, velocity);
|
||||
* (or if transformMatrix is 3x3:)
|
||||
* stateMatrix.transform(position);
|
||||
*/
|
||||
#define COPY(to, from) memcpy(to, from, sizeof(double)* 3);
|
||||
class transformMatrix{
|
||||
private:
|
||||
int N;
|
||||
double *data;
|
||||
bool empty;
|
||||
|
||||
friend class SpiceManager;
|
||||
public:
|
||||
double* ptr() {
|
||||
empty = false;
|
||||
return data;
|
||||
}
|
||||
/* default constructor */
|
||||
transformMatrix();
|
||||
/* default destructor */
|
||||
// ~transformMatrix(){ delete[] data; };
|
||||
/* allocation of memory */
|
||||
transformMatrix(int n) : N(n){
|
||||
data = new double[N*N];
|
||||
empty = true;
|
||||
}
|
||||
|
||||
void transform(glm::dvec3& position) {
|
||||
assert(!empty); // transformation matrix is empty
|
||||
|
||||
double *state;
|
||||
double *state_t;
|
||||
state = new double[N];
|
||||
state_t = new double[N];
|
||||
|
||||
COPY(state, &position);
|
||||
mxvg_c(data, state, N, N, state_t);
|
||||
|
||||
COPY(&position, state_t);
|
||||
}
|
||||
|
||||
/** As the spice function mxvg_c requires a 6dim vector
|
||||
* the two 3dim state vectors are packed into 'state'.
|
||||
* Transformed values are then copied back from state_t
|
||||
* to each corresponding statevector.
|
||||
*
|
||||
* \param position, positional vector to be expressed in
|
||||
* the new reference frame.
|
||||
* \param velocity, (optional) velocity input is only
|
||||
* transformed in conjunction with a 6x6 matrix, otherwise
|
||||
* the method ignores its second argument.
|
||||
*/
|
||||
void transform(glm::dvec3& position,
|
||||
glm::dvec3& velocity) {
|
||||
assert(!empty); // transformation matrix is empty
|
||||
|
||||
double *state;
|
||||
double *state_t;
|
||||
state = new double[N];
|
||||
state_t = new double[N];
|
||||
|
||||
COPY(state, &position);
|
||||
if (N == 6) COPY(state + velocity.length(), &velocity);
|
||||
|
||||
mxvg_c(data, state, N, N, state_t);
|
||||
|
||||
COPY(&position, state_t);
|
||||
if (N == 6) COPY(&velocity, state_t + velocity.length());
|
||||
}
|
||||
/* overloaded operator()
|
||||
* asserts matrix has been filled
|
||||
*/
|
||||
inline double operator()(int i, int j) const{
|
||||
assert(!empty); // transformation matrix is empty
|
||||
return data[j + i*N];
|
||||
}
|
||||
};
|
||||
#undef COPY
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __SPICEMANAGER_H__
|
||||
|
||||
Reference in New Issue
Block a user