Use doubles for coordinates and some bugfixes

This commit is contained in:
Ylva Selling
2021-04-26 14:26:39 +02:00
parent e05a980254
commit b7c4d94df0
7 changed files with 58 additions and 33 deletions

View File

@@ -45,6 +45,8 @@
#include <fstream>
#define _USE_MATH_DEFINES
#include <math.h>
namespace {
struct [[codegen::Dictionary(ScreenSpaceSkyBrowser)]] Parameters {
@@ -330,6 +332,27 @@ void SkyBrowserModule::internalInitialize(const ghoul::Dictionary& dict) {
dataHandler = new WWTDataHandler();
}
glm::dvec3 SkyBrowserModule::icrsToGalacticCartesian(double ra, double dec, double distance) {
// Convert to Galactic Coordinates from ICRS right ascension and declination
// https://gea.esac.esa.int/archive/documentation/GDR2/Data_processing/
// chap_cu3ast/sec_cu3ast_intro/ssec_cu3ast_intro_tansforms.html#SSS1
const glm::dmat3 conversionMatrix = glm::dmat3({
-0.0548755604162154, 0.4941094278755837, -0.8676661490190047, // col 0
-0.8734370902348850, -0.4448296299600112, -0.1980763734312015, // col 1
-0.4838350155487132, 0.7469822444972189, 0.4559837761750669 // col 2
});
double degToRad = M_PI / 180.0;
glm::dvec3 rICRS = glm::dvec3(
cos(ra * degToRad) * cos(dec * degToRad),
sin(ra * degToRad) * cos(dec * degToRad),
sin(dec * degToRad)
);
glm::dvec3 rGalactic = conversionMatrix * rICRS; // on the unit sphere
return distance * rGalactic;
}
glm::vec2 SkyBrowserModule::getMousePositionInScreenSpaceCoords(glm::vec2& mousePos) {
glm::vec2 size = global::windowDelegate->currentWindowSize();
// Change origin to middle of the window