ra dec translation

This commit is contained in:
Agnes Heppich
2018-11-12 17:30:33 -05:00
parent 89e0b20cc4
commit 9aefc203a3
6 changed files with 115 additions and 56 deletions

View File

@@ -21,6 +21,7 @@ asset.require('scene/solarsystem/dsn/stations')
--Communication
--assetHelper.requestAll(asset, 'scene/solarsystem/dsn')
asset.require('scene/solarsystem/dsn/communicationlines/communicationlines')
asset.require('scene/solarsystem/dsn/spacecrafts')
-- Load default key bindings applicable to most scenes
asset.require('util/default_keybindings')

View File

@@ -0,0 +1,36 @@
local assetHelper = asset.require('util/asset_helper')
local models = asset.syncedResource({
Name = "Dsn models",
Type = "HttpSynchronization",
Identifier = "dsn_stations",
Version = 1
})
local testSpaceCraft = {
Identifier = "testSpaceCraft",
Transform = {
Translation = {
Type = "RadecTranslation"
},
Scale = {
Type = "StaticScale",
Scale = 1000.0
}
},
Renderable = {
Type = "RenderableModel",
Geometry = {
Type = "MultiModelGeometry",
GeometryFile = models .. "/34m_dish/34m_dish.obj"
},
ColorTexture = models .. "/34m_dish/base_AO.png",
},
GUI = {
Name = "testSpaceCraft",
Path = "/Solar System/testSpaceCraft"
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {testSpaceCraft})

View File

@@ -390,8 +390,29 @@ void RenderableSignals::pushSignalDataToVertexArray(SignalManager::Signal signal
_vertexArray.push_back(color.b);
_vertexArray.push_back(color.a);
}
//For testing
glm::vec3 worldTestPos = getSuitablePrecisionPositionForSceneGraphNode("testSpaceCraft");
_vertexArray.push_back(posStation.x);
_vertexArray.push_back(posStation.y);
_vertexArray.push_back(posStation.z);
_vertexArray.push_back(color.r);
_vertexArray.push_back(color.g);
_vertexArray.push_back(color.b);
_vertexArray.push_back(color.a);
_vertexArray.push_back(worldTestPos.x);
_vertexArray.push_back(worldTestPos.y);
_vertexArray.push_back(worldTestPos.z);
_vertexArray.push_back(color.r);
_vertexArray.push_back(color.g);
_vertexArray.push_back(color.b);
_vertexArray.push_back(color.a);
}
/* Since our station dishes have a static translation from Earth, we
* can get their local translation. The reason to handle it differently
@@ -408,21 +429,6 @@ glm::dvec3 RenderableSignals::getCoordinatePosFromFocusNode(SceneGraphNode* node
return diff;
}
glm::dvec3 RenderableSignals::getEstimatedCoordinatePosFromFocusNode(glm::vec3 pos) {
glm::dvec3 earthPos = global::renderEngine.scene()->sceneGraphNode("Earth")->worldPosition();
glm::dvec3 focusNodePos = _focusNode->worldPosition();
glm::dmat4 translationMatrixEarth = glm::translate(glm::dmat4(1.0), glm::dvec3(earthPos));
glm::dvec4 newPos = { pos, 1.0 };
glm::dvec4 nodePos = _rotEquatorialSphere * translationMatrixEarth *newPos;
glm::dvec3 diff = glm::vec3(nodePos.x - focusNodePos.x, nodePos.y - focusNodePos.y,
nodePos.z - focusNodePos.z);
return diff;
}
glm::vec3 RenderableSignals::getSuitablePrecisionPositionForSceneGraphNode(std::string id) {
@@ -434,7 +440,7 @@ glm::vec3 RenderableSignals::getSuitablePrecisionPositionForSceneGraphNode(std::
}
else {
//If no scenegraphnode with proper id was found, estimate the position of the spacecraft by RA/DEC/RANGE
position = convertRaDecRangeToCartesian();
//position = convertRaDecRangeToCartesian();
}
return position;
@@ -457,27 +463,6 @@ glm::vec3 RenderableSignals::getPositionForGeocentricSceneGraphNode(const char*
}
glm::dvec3 RenderableSignals::convertRaDecRangeToCartesian() {
//Todo: stream data from file
//Dummy data for voyager 1
double ra = 257.777029167736; //2018-246
double dec = 12.2537708651048; // 2018-246
double range = 2.14044781771236e+13;
// Convert RA and DEC from degrees to radians
ra = glm::radians(ra);
dec = glm::radians(dec);
//Save array in vector
glm::dvec3 raDecPos = SpiceManager::getPositionFromRaDecRange(ra,dec,range);
//Get the RA / DEC values in world coordinates with respect to the current focus node
raDecPos = getEstimatedCoordinatePosFromFocusNode(raDecPos);
return raDecPos;
}
RenderableSignals::ColorVBOLayout RenderableSignals::getSiteColor(std::string dishidentifier) {
glm::vec3 color(0.0f,0.0f,0.0f);

View File

@@ -86,10 +86,6 @@ namespace openspace {
void pushSignalDataToVertexArray(SignalManager::Signal signal);
/* Returns a position relative the current focus node */
glm::dvec3 getCoordinatePosFromFocusNode(SceneGraphNode* node);
/* Returns the estimated position expressed relative to the current focusnode */
glm::dvec3 getEstimatedCoordinatePosFromFocusNode(glm::vec3 pos);
/* Converts the Ra Dec range coordinates into cartesian coordinates*/
glm::dvec3 convertRaDecRangeToCartesian();
/*Returns a position for a spacecraft*/
glm::vec3 getSuitablePrecisionPositionForSceneGraphNode(std::string id);
/*Returns a position for a station that has Earth as parent*/
@@ -193,11 +189,8 @@ namespace openspace {
/*Checks if the current time is within a signal's start and endtime*/
bool isSignalActive(double currentTime, std::string signalStartTime, std::string signalEndTime);
/* Rotation matrix to transform into equatorial sphere coordinate system*/
glm::dmat4 _rotEquatorialSphere = { -0.05487554, 0.4941095, -0.8676661, 0.0,
-0.8734371 , -0.4448296, -0.1980764, 0.0,
-0.483835 , 0.7469823, 0.4559838, 0.0,
0.0 , 0.0 , 0.0 , 1.0 };
};
} // namespace openspace

View File

@@ -23,7 +23,6 @@
****************************************************************************************/
#include <modules/dsn/translation/radectranslation.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
@@ -51,7 +50,7 @@ documentation::Documentation RadecTranslation::Documentation() {
{
PositionInfo.identifier,
new DoubleVector3Verifier,
Optional::No,
Optional::Yes,
PositionInfo.description
}
}
@@ -66,7 +65,9 @@ RadecTranslation::RadecTranslation()
glm::dvec3(-std::numeric_limits<double>::max()),
glm::dvec3(std::numeric_limits<double>::max())
)
{
{
addProperty(_position);
_position.onChange([this]() {
@@ -83,11 +84,42 @@ RadecTranslation::RadecTranslation(const ghoul::Dictionary& dictionary)
dictionary,
"RadecTranslation"
);
_position = dictionary.value<glm::dvec3>(PositionInfo.identifier);
}
glm::dvec3 RadecTranslation::position(const UpdateData&) const {
glm::dvec3 RadecTranslation::convertRaDecRangeToCartesian() const{
//Todo: stream data from file
//Static data for voyager 1
double ra = 257.777029167736; //2018-246
double dec = 12.2537708651048; // 2018-246
double range = 2.14044781771236e+13;
//Convert RA and DEC from degrees to radians
ra = glm::radians(ra);
dec = glm::radians(dec);
//Save array in vector
glm::dvec3 raDecPos = SpiceManager::getPositionFromRaDecRange(ra, dec, range);
return raDecPos;
}
glm::dvec3 RadecTranslation::transformCartesianCoordinates() const {
glm::vec3 pos = convertRaDecRangeToCartesian();
glm::dvec3 earthPos = global::renderEngine.scene()->sceneGraphNode("Earth")->worldPosition();
glm::dmat4 translationMatrixEarth = glm::translate( glm::dmat4(1.0), glm::dvec3(earthPos) );
glm::dvec4 newPos = { pos, 1.0 };
glm::dvec4 nodePos = translationMatrixEarth * _rotEquatorialSphere * newPos;
glm::dvec3 worldposition = { nodePos.x, nodePos.y, nodePos.z };
return worldposition;
}
glm::dvec3 RadecTranslation::position(const UpdateData&) const{
glm::dvec3 _position = transformCartesianCoordinates();
return _position;
}

View File

@@ -26,8 +26,11 @@
#define __OPENSPACE_MODULE_DSN___RADECTRANSLATION___H__
#include <openspace/scene/translation.h>
#include <openspace/util/spicemanager.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/properties/vector/dvec3property.h>
#include <modules/dsn/rendering/renderablesignals.h>
namespace openspace {
@@ -39,14 +42,23 @@ class RadecTranslation : public Translation {
public:
RadecTranslation();
RadecTranslation(const ghoul::Dictionary& dictionary);
/* Converts the Ra Dec range coordinates into cartesian coordinates*/
glm::dvec3 convertRaDecRangeToCartesian() const;
/*Transforms the cartesian coordinates with a rotation and a translation*/
glm::dvec3 transformCartesianCoordinates() const;
glm::dvec3 position(const UpdateData& data) const override;
static documentation::Documentation Documentation();
private:
properties::DVec3Property _position;
};
glm::dmat4 _rotEquatorialSphere = { -0.05487554, 0.4941095, -0.8676661, 0.0,
-0.8734371 , -0.4448296, -0.1980764, 0.0,
-0.483835 , 0.7469823, 0.4559838, 0.0,
0.0 , 0.0 , 0.0 , 1.0
};
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_DSN___RADECTRANSLATION___H__