Skip to content
Permalink
Browse files

.

  • Loading branch information...
ri
ri committed Apr 14, 2019
1 parent 144ada2 commit afa4700186d6425de992f2ca8843dd48b3badf5b
Showing with 76 additions and 79 deletions.
  1. +52 −47 SatViewer.cpp
  2. +1 −1 SatViewer.h
  3. +4 −3 models/sgp4/Sgp4Model.cpp
  4. +12 −6 ogl/RadarWidget.cpp
  5. +4 −15 satutils/Satellite.cpp
  6. +3 −7 satutils/Satellite.h
@@ -5,6 +5,8 @@
* Created on April 13, 2019, 9:45 PM
*/

#include <cfloat>

#include "SatViewer.h"

SatViewer::SatViewer() {
@@ -121,51 +123,54 @@ void SatViewer::setTime(double value) {
emit timeChanged();
}

void SatViewer::aerv() {
// double aerv[4];
// double m[3][3];
// Satellite *sat;
// sat->xyz_g()
// double d[3];
// double p = sqrt(xyzLoc[0] * xyzLoc[0] + xyzLoc[1] * xyzLoc[1]);
// double r = sqrt(xyzLoc[0] * xyzLoc[0] + xyzLoc[1] * xyzLoc[1] + xyzLoc[2] * xyzLoc[2]);
//
// double dd[] = {
// xyzLoc[0] - xyzSat[0],
// xyzLoc[1] - xyzSat[1],
// xyzLoc[2] - xyzSat[2],
// xyzLoc[3] - xyzSat[3],
// xyzLoc[4] - xyzSat[4],
// xyzLoc[5] - xyzSat[5]
// };
//
// aerv[2] = sqrt(dd[0] * dd[0] + dd[1] * dd[1] + dd[2] * dd[2]);
//
// if (p < Number.EPSILON || r < Number.EPSILON) {
// return aerv;
// }
//
// m[0][0] = -xyzLoc[1] / p;
// m[0][1] = xyzLoc[0] / p;
// m[0][2] = 0.0;
// m[1][0] = -(xyzLoc[0] * xyzLoc[2] / (p * r));
// m[1][1] = -(xyzLoc[1] * xyzLoc[2] / (p * r));
// m[1][2] = p / r;
// m[2][0] = xyzLoc[0] / r;
// m[2][1] = xyzLoc[1] / r;
// m[2][2] = xyzLoc[2] / r;
//
// for (size_t j = 0; j < 3; j++) {
// for (size_t i = 0; i < 3; i++) {
// d[j] += (xyzSat[i] - xyzLoc[i]) * m[j][i];
// }
// }
//
// double s = d[2] / sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
//
// aerv[1] = atan2(s, sqrt(1.0 - s * s));
// aerv[0] = atan2(d[0], d[1]);
// aerv[3] = (dd[0] * dd[3] + dd[1] * dd[4] + dd[2] * dd[5]) / aerv[2];
//
// return aerv;
void SatViewer::aerv(const double loc_rg[], const double sat_rg[], double aerv[]) {
double m[3][3];

double d[3];
double p = sqrt(loc_rg[0] * loc_rg[0] + loc_rg[1] * loc_rg[1]);
double r = sqrt(loc_rg[0] * loc_rg[0] + loc_rg[1] * loc_rg[1] + loc_rg[2] * loc_rg[2]);

double dd[] = {
loc_rg[0] - sat_rg[0],
loc_rg[1] - sat_rg[1],
loc_rg[2] - sat_rg[2],
loc_rg[3] - sat_rg[3],
loc_rg[4] - sat_rg[4],
loc_rg[5] - sat_rg[5]
};

aerv[2] = sqrt(dd[0] * dd[0] + dd[1] * dd[1] + dd[2] * dd[2]);

if ((p < DBL_EPSILON) || (r < DBL_EPSILON)) {
aerv[0] = 0.0;
aerv[1] = 0.0;
aerv[2] = 0.0;
aerv[3] = 0.0;
aerv[4] = 0.0;
aerv[5] = 0.0;
return;
}

m[0][0] = -loc_rg[1] / p;
m[0][1] = loc_rg[0] / p;
m[0][2] = 0.0;
m[1][0] = -(loc_rg[0] * loc_rg[2] / (p * r));
m[1][1] = -(loc_rg[1] * loc_rg[2] / (p * r));
m[1][2] = p / r;
m[2][0] = loc_rg[0] / r;
m[2][1] = loc_rg[1] / r;
m[2][2] = loc_rg[2] / r;

for (size_t j = 0; j < 3; j++) {
d[j] = 0.0;
for (size_t i = 0; i < 3; i++) {
d[j] += (sat_rg[i] - loc_rg[i]) * m[j][i];
}
}

double s = d[2] / sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);

aerv[0] = atan2(d[0], d[1]);
aerv[1] = atan2(s, sqrt(1.0 - s * s));
aerv[3] = (dd[0] * dd[3] + dd[1] * dd[4] + dd[2] * dd[5]) / aerv[2];
}
@@ -18,6 +18,7 @@ class SatViewer : public QObject {
SatViewer();
SatViewer(const SatViewer& orig);
virtual ~SatViewer();
static void aerv(const double loc_rg[], const double sat_rg[], double aerv[]);
void appendSatellite(Satellite* sat);
void appendLocation(Location* loc);
void removeSatellite(Satellite *sat);
@@ -45,7 +46,6 @@ class SatViewer : public QObject {
Location *m_currentLocation;
double m_time;
ZrvIoList m_ioList;
static void aerv();

};

@@ -76,7 +76,7 @@ bool Sgp4Model::modelInit(char *state, int size) {

bool Sgp4Model::model(double time) {
bool result;

time = (2440587.5 - state.jdsatepoch + time / 86400.0) * 1440.0;
result = SGP4Funcs::sgp4(elset, time, m_r, m_r + 3);

@@ -87,7 +87,8 @@ bool Sgp4Model::model(double time) {
m_r[4] *= 1000.0;
m_r[5] *= 1000.0;

getGeod();

makeGeod();
makeRg();

return result;
}
@@ -63,6 +63,7 @@ void RadarWidget::compileSatList() {
GLfloat px, py, tmpx, tmpy, tper = 0;
GLfloat trackBegin, trackEnd;
GLuint clr;
double aerv[4];

Location *loc = m_satviewer->currentLocation();

@@ -93,12 +94,14 @@ void RadarWidget::compileSatList() {
trackBegin = sat->track() * (-0.5 * tper + tper / 180.0);
trackEnd = sat->track() * (0.5 * tper + tper / 180.0);
sat->model(trackBegin + m_satviewer->time());
tmpx = sat->longitude() / M_PI;
tmpy = -2.0 * sat->latitude() / M_PI;
SatViewer::aerv(loc->rg(), sat->rg(), aerv);
tmpx = (M_PI_2 - aerv[1]) * sin(aerv[0]) / M_PI_2;
tmpy = (aerv[1] - M_PI_2) * cos(aerv[0]) / M_PI_2;
for (double i = trackBegin; i < trackEnd; i += tper / 180.0) {
sat->model(i + m_satviewer->time());
px = sat->longitude() / M_PI;
py = -2.0 * sat->latitude() / M_PI;
SatViewer::aerv(loc->rg(), sat->rg(), aerv);
px = (M_PI_2 - aerv[1]) * sin(aerv[0]) / M_PI_2;
py = (aerv[1] - M_PI_2) * cos(aerv[0]) / M_PI_2;
if (fabs(px - tmpx) > 1.75) {
if (px > tmpx) {
glVertex2f(-1.0, 0.5 * (py + tmpy));
@@ -122,8 +125,11 @@ void RadarWidget::compileSatList() {
}

sat->model(m_satviewer->time());
px = sat->longitude() / M_PI;
py = -2.0 * sat->latitude() / M_PI;
// px = sat->longitude() / M_PI;
// py = -2.0 * sat->latitude() / M_PI;
SatViewer::aerv(loc->rg(), sat->rg(), aerv);
px = (M_PI_2 - aerv[1]) * sin(aerv[0]) / M_PI_2;
py = (aerv[1] - M_PI_2) * cos(aerv[0]) / M_PI_2;
if (sat->satWObject) {
sat->satWObject->exec(px, py, 0.0);
}
@@ -34,7 +34,7 @@ Satellite::Satellite(void) {
color_track_shadow = 0xFF407464;

_track = 0.5;
satWObject = NULL;
satWObject = nullptr;
satellite = true;
location = false;
radius_earth = 0.0;
@@ -61,7 +61,7 @@ Satellite::~Satellite(void) {
qWarning("satellite is removed");
}

void Satellite::getGeod() {
void Satellite::makeGeod() {
double p, T, sT, cT, N;
double const WZ = 7.2921151467e-5;
double const a_axis = 6378137.0; //WGS-84 earth's semi major axis
@@ -118,7 +118,7 @@ void Satellite::setName(QString name) {
_name = name;
}

double *Satellite::rg() {
void Satellite::makeRg() {
double const WZ = 7.2921151467e-5; // TODO
double alpha = WZ * minutes() * 60.0 + gsto();
m_rg[0] = cos(alpha) * m_r[0] + sin(alpha) * m_r[1];
@@ -127,18 +127,7 @@ double *Satellite::rg() {
m_rg[3] = cos(alpha) * m_r[3] + sin(alpha) * m_r[4] + WZ * m_rg[1];
m_rg[4] = -sin(alpha) * m_r[3] + cos(alpha) * m_r[4] - WZ * m_rg[0];
m_rg[5] = m_r[5];
return m_rg;
}

//double* Satellite::vxyz_g() {
// double const WZ = 7.2921151467e-5;
// double alpha = WZ * minutes() * 60.0 + gsto();
// xyz_g();
// v_g[0] = cos(alpha) * v[0] + sin(alpha) * v[1] + WZ * r_g[1];
// v_g[1] = -sin(alpha) * v[0] + cos(alpha) * v[1] - WZ * r_g[0];
// v_g[2] = v[2];
// return v_g;
//}
}

void Satellite::setZrv(double value) {
if (value > M_PI_2) {
@@ -42,7 +42,7 @@ class Satellite {
double nameY() const { return name_y; }

double *r() { return m_r; }
// double* vxyz() { return v; }
double *rg() { return m_rg; }

double latitude () const { return lat; }
double longitude () const { return lon; }
@@ -86,9 +86,6 @@ class Satellite {
bool isAtctiveZone () const { return active_zone; }
bool isVisibleTrackShadow() const { return show_track_shadow; }

double *rg();
// double* vxyz_g();

void setLocation(bool location);
bool isLocation() const;
void setSatellite(bool satellite);
@@ -97,12 +94,11 @@ class Satellite {
protected:
double lon, lat, _altitude;
double m_r[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
// double v[3] = {0.0, 0.0, 0.0};
double m_rg[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
// double v_g[3] = {0.0, 0.0, 0.0};
double zrv;
double radius_earth;
void getGeod();
void makeGeod();
void makeRg();
virtual double gsto() { return 0.0; }
virtual double minutes() { return 0.0; }

0 comments on commit afa4700

Please sign in to comment.
You can’t perform that action at this time.