SegmentNoaa::SegmentNoaa(QFile *filesegment, SatelliteList *satl, QObject *parent) : Segment(parent) { bool ok; satlist = satl; fileInfo.setFile(*filesegment); segment_type = "Noaa"; segtype = eSegmentType::SEG_NOAA; int sensing_start_year = fileInfo.fileName().mid(6, 4).toInt( &ok , 10); int sensing_start_month = fileInfo.fileName().mid(10, 2).toInt( &ok, 10); int sensing_start_day = fileInfo.fileName().mid(12, 2).toInt( &ok, 10); int sensing_start_hour = fileInfo.fileName().mid(15, 2).toInt( &ok, 10); int sensing_start_minute = fileInfo.fileName().mid(17, 2).toInt( &ok, 10); int sensing_start_second = fileInfo.fileName().mid(19, 2).toInt( &ok, 10); //this->sensing_start_year = sensing_start_year; qdatetime_start.setDate(QDate(sensing_start_year, sensing_start_month, sensing_start_day)); qdatetime_start.setTime(QTime(sensing_start_hour,sensing_start_minute, sensing_start_second)); qsensingstart = QSgp4Date(sensing_start_year, sensing_start_month, sensing_start_day, sensing_start_hour, sensing_start_minute, sensing_start_second); qsensingend = qsensingstart; qsensingend.AddMin(1.0); julian_sensing_start = qsensingstart.Julian(); julian_sensing_end = qsensingend.Julian(); this->earth_views_per_scanline = 2048; Satellite noaa19; ok = satlist->GetSatellite(33591, &noaa19); line1 = noaa19.line1; line2 = noaa19.line2; //line1 = "1 33591U 09005A 11039.40718334 .00000086 00000-0 72163-4 0 8568"; //line2 = "2 33591 98.8157 341.8086 0013952 344.4168 15.6572 14.11126791103228"; qtle.reset(new QTle(noaa19.sat_name, line1, line2, QTle::wgs72)); qsgp4.reset(new QSgp4( *qtle )); julian_state_vector = qtle->Epoch(); minutes_since_state_vector = ( julian_sensing_start - julian_state_vector ) * MIN_PER_DAY; // + (1.0/12.0) / 60.0; minutes_sensing = 1; QEci eci; qsgp4->getPosition(minutes_since_state_vector, eci); QGeodetic geo = eci.ToGeo(); lon_start_rad = geo.longitude; lat_start_rad = geo.latitude; lon_start_deg = lon_start_rad * 180.0 / PI; lat_start_deg = lat_start_rad * 180.0 /PI; NbrOfLines = 360; CalculateCornerPoints(); }
void SatGL::RenderTrail(Satellite *sat, QMatrix4x4 projection, float distance, QQuaternion quat, bool trackon) // QMatrix4x4 modelview, bool trackon) { QVector<GLfloat> postrail; double tsince, // Time since epoch (in minutes) jul_epoch, // Julian date of epoch jul_utc; // Julian UTC date QSgp4Date nowutc = QSgp4Date::NowUTC(); jul_utc = nowutc.Julian(); jul_epoch = Julian_Date_of_Epoch(sat->GetEpoch()); QMatrix4x4 model; model.translate(0.0, 0.0, distance); model.rotate(quat); QMatrix4x4 modelview; modelview = model; QMatrix4x4 modelocta; QColor col(0,255,255); QEci qeci; QVector3D pos; double id; int nbrVertices = 0; tsince = (jul_utc - jul_epoch) * MIN_PER_DAY; // in minutes for( id = tsince - 5; id < tsince; id++ ) { (*sat).qsgp4->getPosition(id, qeci); QGeodetic qgeo = qeci.ToGeo(); LonLat2PointRad(qgeo.latitude, qgeo.longitude, &pos, 1.001f); if(id < tsince && id >= tsince - 5 ) { modelocta = model; modelocta.translate(pos.x(), pos.y(), pos.z()); modelocta.scale(0.004f); octa->render(projection, modelocta, col); } } if(trackon) { for( id = tsince - opts.realminutesshown + 1; id <= tsince + opts.realminutesshown; id++ ) // nbr of id's = 2 * opts.realminutesshown { (*sat).qsgp4->getPosition(id, qeci); QGeodetic qgeo = qeci.ToGeo(); LonLat2PointRad(qgeo.latitude, qgeo.longitude, &pos, 1.001f); postrail.append(pos.x()); postrail.append(pos.y()); postrail.append(pos.z()); } positionsTrail.bind(); if(tdiff != opts.realminutesshown) { tdiff = opts.realminutesshown; positionsTrail.allocate(postrail.data(), postrail.size() * sizeof(GLfloat)); } else { positionsTrail.write(0, postrail.data(), postrail.size() * sizeof(GLfloat)); } nbrVertices = positionsTrail.size() / (3 * sizeof(GLfloat)); positionsTrail.release(); QOpenGLVertexArrayObject::Binder vaoBinder(&vaotrail); program->bind(); program->setUniformValue("MVP", projection * modelview); QMatrix3x3 norm = modelview.normalMatrix(); program->setUniformValue("NormalMatrix", norm); QColor rendercolor(opts.sattrackcolor); program->setUniformValue("outcolor", QVector4D(rendercolor.redF(), rendercolor.greenF(), rendercolor.blueF(), 1.0f)); glDrawArrays(GL_LINE_STRIP, 0, nbrVertices); } }
void SegmentNoaa::RenderSegmentlineInProjectionAlternative( int channel, int nbrLine, int heightintotalimage, QEci eciref, double ang_vel, eProjections proj) { QRgb *row_col; double map_x, map_y; QRgb rgbvalue = qRgb(0,0,0); if (channel == 6) row_col = (QRgb*)imageptrs->ptrimagecomp_col->scanLine(heightintotalimage); else if (channel == 1) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[0]->scanLine(heightintotalimage); else if (channel == 2) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[1]->scanLine(heightintotalimage); else if (channel == 3) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[2]->scanLine(heightintotalimage); else if (channel == 4) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[3]->scanLine(heightintotalimage); else if (channel == 5) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[4]->scanLine(heightintotalimage); QSgp4Date dateref = eciref.GetDate(); Vector3 posref = eciref.GetPos(); Vector3 velref = eciref.GetVel(); for ( int nbrPoint = 0; nbrPoint < this->earth_views_per_scanline; nbrPoint++ ) { double deltat = (double)nbrPoint/(6.0 * this->earth_views_per_scanline); // in seconden double deltax = NEW_NOAA_SWATH / ((this->earth_views_per_scanline / 2) - 0.5); //double deltax = (double)FOV_STEP_ANGLE; //double deltax = 0.0009439882; // * 1023.5; //0.0009439882 * 1023.5; //double deltax = 0.0009400; QEci eciaprox = eciref.CircularApprox(deltat, ang_vel); double Off_Nadir_Angle = deltax * ((nbrPoint - (this->earth_views_per_scanline/2))+0.5); // in rad Vector3 pos = eciaprox.GetPos(); Vector3 vel = eciaprox.GetVel(); QSgp4Date dat = eciaprox.GetDate(); Vector3 posnorm = pos; posnorm = posnorm.normalize(); Vector3 scan = pos.cross(vel); Vector3 scannorm = scan; scannorm = scannorm.normalize(); double posmag = pos.length(); // range vector from satellite for a spherical earth double cosoffnadir = cos(Off_Nadir_Angle); double sinoffnadir = sin(Off_Nadir_Angle); Vector3 rangevectornorm = - posnorm * cosoffnadir + scannorm * sinoffnadir; double squareradiusearthkm = this->qtle->radiusearthkm * this->qtle->radiusearthkm; double squareradiusearthkmminor = this->qtle->radiusearthkmminor * this->qtle->radiusearthkmminor; double epsilon = ( squareradiusearthkm / squareradiusearthkmminor) - 1; //double firstterm = sqrt(this->qtle->radiusearthkm * this->qtle->radiusearthkm - posmag * posmag * sinoffnadir * sinoffnadir); //double range_distance = posmag * cosoffnadir - firstterm; double firstterm = 1 + (epsilon * rangevectornorm.z * rangevectornorm.z); double secterm = posmag * cosoffnadir - epsilon * pos.z * rangevectornorm.z; double thirdterm = squareradiusearthkm - posmag * posmag - epsilon * pos.z * pos.z + secterm * secterm; double range_distance = (secterm / firstterm) - sqrt( thirdterm / firstterm ) ; /* double firstterm = 1 + (epsilon * rangevectornorm.z * rangevectornorm.z); double secterm = epsilon * pos.z * rangevectornorm.z - posmag * cosoffnadir; double thirdterm = posmag * posmag - squareradiusearthkm + epsilon * pos.z * pos.z; double determinant = secterm * secterm - firstterm * thirdterm; double fourthterm = posmag * cosoffnadir - epsilon * pos.z * rangevectornorm.z - sqrt(determinant); double range_distance = fourthterm / firstterm; */ Vector3 rangevector = rangevectornorm * range_distance; Vector3 location = pos + rangevector; /////////////////////////////////////////// //const double theta = Util::AcTan(location.y, location.x); //double lonpos = fmod(theta - dat.ToGreenwichSiderealTime(), TWOPI); //double r = sqrt(location.x * location.x + location.y * location.y); //double latpos = Util::AcTan(location.z, r); /////////////////////////////////////////////// QEci ecilocation(location, vel, dat ); QGeodetic geolocation = ecilocation.ToGeo(); double lonpos = geolocation.longitude; double latpos = geolocation.latitude; ///////////////////////////////////////////// if(proj == LCC) { if(imageptrs->lcc->map_forward(lonpos, latpos, map_x, map_y)) { if (map_x > 0 && map_x < imageptrs->ptrimageProjection->width() && map_y > 0 && map_y < imageptrs->ptrimageProjection->height()) { if(opts.sattrackinimage) { if( nbrPoint == 1023 || nbrPoint == 1024) rgbvalue = qRgb(255, 0, 0); else rgbvalue =qRgb(qRed(row_col[nbrPoint]), qGreen(row_col[nbrPoint]), qBlue(row_col[nbrPoint])); } else rgbvalue =qRgb(qRed(row_col[nbrPoint]), qGreen(row_col[nbrPoint]), qBlue(row_col[nbrPoint])); imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); // qDebug() << QString("map_x = %1 map_y = %2").arg(map_x).arg(map_y); } } } else if(proj == GVP) { if(imageptrs->gvp->map_forward(lonpos, latpos, map_x, map_y)) { if (map_x > 0 && map_x < imageptrs->ptrimageProjection->width() && map_y > 0 && map_y < imageptrs->ptrimageProjection->height()) { if(opts.sattrackinimage) { if( nbrPoint == 1023 || nbrPoint == 1024) rgbvalue = qRgb(255, 0, 0); else rgbvalue =qRgb(qRed(row_col[nbrPoint]), qGreen(row_col[nbrPoint]), qBlue(row_col[nbrPoint])); } else rgbvalue =qRgb(qRed(row_col[nbrPoint]), qGreen(row_col[nbrPoint]), qBlue(row_col[nbrPoint])); imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); // qDebug() << QString("map_x = %1 map_y = %2").arg(map_x).arg(map_y); } } } else if(proj == SG) { if(imageptrs->sg->map_forward(lonpos, latpos, map_x, map_y)) { if (map_x > 0 && map_x < imageptrs->ptrimageProjection->width() && map_y > 0 && map_y < imageptrs->ptrimageProjection->height()) { if(opts.sattrackinimage) { if( nbrPoint == 1023 || nbrPoint == 1024) rgbvalue = qRgb(255, 0, 0); else rgbvalue =qRgb(qRed(row_col[nbrPoint]), qGreen(row_col[nbrPoint]), qBlue(row_col[nbrPoint])); } else rgbvalue =qRgb(qRed(row_col[nbrPoint]), qGreen(row_col[nbrPoint]), qBlue(row_col[nbrPoint])); imageptrs->ptrimageProjection->setPixel((int)map_x, (int)map_y, rgbvalue); // qDebug() << QString("map_x = %1 map_y = %2").arg(map_x).arg(map_y); } } } //qDebug() << QString("lonpos = %1 latpos = %2 Angle = %3 posmag = %4 rangvector = %5 firstterm = %6 secterm = %7 posnorm = %8 scan x = %9 y = %10 z = %11").arg(Util::RadiansToDegrees(lonpos)).arg(Util::RadiansToDegrees(latpos)) // .arg(Off_Nadir_Angle).arg(posmag).arg(rangevector.Magnitude()).arg(firstterm).arg(secterm).arg(posnorm.Magnitude()).arg(scan.x).arg(scan.y).arg(scan.z); //double dotprod = pos.Dot(location); //double phi = acos(dotprod / ( pos.Magnitude()*location.Magnitude())); //qDebug() << QString("nbrLine = %1 nbrPoint = %2 off_nadir angle = %3 phi = %4 range_disctance = %5").arg(nbrLine).arg(nbrPoint).arg(Util::RadiansToDegrees(Off_Nadir_Angle)).arg(Util::RadiansToDegrees(phi)) // .arg(range_distance); } }
void SegmentNoaa::RenderSegmentlineInProjection( int channel, int nbrLine, int heightintotalimage, QEci eciref, double ang_vel, eProjections proj) { QRgb *row_col; if (channel == 6) row_col = (QRgb*)imageptrs->ptrimagecomp_col->scanLine(heightintotalimage); else if (channel == 1) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[0]->scanLine(heightintotalimage); else if (channel == 2) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[1]->scanLine(heightintotalimage); else if (channel == 3) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[2]->scanLine(heightintotalimage); else if (channel == 4) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[3]->scanLine(heightintotalimage); else if (channel == 5) row_col = (QRgb*)imageptrs->ptrimagecomp_ch[4]->scanLine(heightintotalimage); QSgp4Date dateref = eciref.GetDate(); Vector3 posref = eciref.GetPos(); Vector3 velref = eciref.GetVel(); QGeodetic georef = eciref.ToGeo(); Vector3 scan = posref.cross(velref); Vector3 posrefnorm = posref; posrefnorm = posrefnorm.normalize(); Vector3 scannorm = scan; scannorm = scannorm.normalize(); //double delta = 0.0009457 * 1023.5; //0.0009439882 * 1023.5; double delta = 0.0009480 * 1023.5; double r = posref.length(); double sindelta = sin(-delta); double dd = r * cos(-delta) - sqrt(this->qtle->radiusearthkm * this->qtle->radiusearthkm - r * r * sindelta * sindelta); Vector3 d3d = - posrefnorm * cos(-delta) * dd + scannorm * sin(-delta) * dd; //qDebug() << QString("a = %1 b = %2").arg(XKMPER * XKMPER).arg( r * r * sindelta * sindelta); Vector3 d3earthposfirst = posref + d3d; QEci ecifirst(d3earthposfirst, velref, dateref, QTle::wgs72); QGeodetic geofirst = ecifirst.ToGeo(); sindelta = sin(delta); dd = r * cos(delta) - sqrt(this->qtle->radiusearthkm * this->qtle->radiusearthkm - r * r * sindelta * sindelta); d3d = - posrefnorm * cos(delta) * dd + scannorm * sin(delta) * dd; Vector3 d3earthposlast = posref + d3d; QSgp4Date newdate; newdate.Set(dateref.Julian() + (1/6) * (1.0/ (24.0 * 60.0 * 60.0)), false); QEci ecilast(d3earthposlast, velref, newdate, QTle::wgs72); QGeodetic geolast = ecilast.ToGeo(); RenderSegmentlineInProjectionCirc(row_col, nbrLine, geofirst.latitude, geofirst.longitude, geolast.latitude, geolast.longitude, georef.altitude, proj); }
void SegmentGL::RenderContour(Segment *seg, QMatrix4x4 projection, QMatrix4x4 modelview, int width, int height) { QVector3D vec; QVector3D pos; QVector<GLfloat> positions; QEci qeci; CalculateSegmentContour(&positions, seg->cornerpointfirst1.latitude, seg->cornerpointfirst1.longitude, seg->cornerpointlast1.latitude, seg->cornerpointlast1.longitude); CalculateSegmentContour(&positions,seg->cornerpointlast1.latitude, seg->cornerpointlast1.longitude, seg->cornerpointlast2.latitude, seg->cornerpointlast2.longitude); CalculateSegmentContour(&positions, seg->cornerpointlast2.latitude, seg->cornerpointlast2.longitude, seg->cornerpointfirst2.latitude, seg->cornerpointfirst2.longitude); CalculateSegmentContour(&positions,seg->cornerpointfirst2.latitude, seg->cornerpointfirst2.longitude, seg->cornerpointfirst1.latitude, seg->cornerpointfirst1.longitude); seg->qsgp4->getPosition(seg->minutes_since_state_vector, qeci); QGeodetic qgeo = qeci.ToGeo(); double lat1 = qgeo.latitude; double lon1 = qgeo.longitude; seg->qsgp4->getPosition(seg->minutes_since_state_vector + seg->minutes_sensing, qeci); qgeo = qeci.ToGeo(); double lat2 = qgeo.latitude; double lon2 = qgeo.longitude; CalculateSegmentContour(&positions, lat1, lon1, lat2, lon2); positionsBuf.bind(); positionsBuf.write(0, positions.data(), positions.size() * sizeof(GLfloat)); positionsBuf.release(); QOpenGLVertexArrayObject::Binder vaoBinder(&vao); program->bind(); program->setUniformValue("MVP", projection * modelview); QColor rendercolor(opts.satsegmentcolor); QColor rendercolorsel(opts.satsegmentcolorsel); if((*seg).segmentselected) program->setUniformValue("outcolor", QVector4D(rendercolorsel.redF(), rendercolorsel.greenF(), rendercolorsel.blueF(), 1.0f)); else program->setUniformValue("outcolor", QVector4D(rendercolor.redF(), rendercolor.greenF(), rendercolor.blueF(), 1.0f)); QMatrix3x3 norm = modelview.normalMatrix(); program->setUniformValue("NormalMatrix", norm); glDrawArrays(GL_LINE_LOOP, 0, nbrOfVertices - 10); glDrawArrays(GL_LINE_STRIP, nbrOfVertices - 10, 10); float mvmatrix[16], projmatrix[16]; QMatrix4x4 MVP; MVP = projection * modelview; float *ptr = modelview.data(); for(int i = 0; i < 16; i++) mvmatrix[i] = *(ptr + i); ptr = projection.data(); for(int i = 0; i < 16; i++) projmatrix[i] = *(ptr + i); QVector2D win; LonLat2PointRad((float)seg->cornerpointfirst1.latitude, (float)seg->cornerpointfirst1.longitude, &vec, 1.0); win = glhProjectf (vec, mvmatrix, projmatrix, width, height); seg->winvecend1 = win; LonLat2PointRad((float)seg->cornerpointfirst2.latitude, (float)seg->cornerpointfirst2.longitude, &vec, 1.0); win = glhProjectf (vec, mvmatrix, projmatrix, width, height); seg->winvecend2 = win; LonLat2PointRad((float)seg->cornerpointlast1.latitude, (float)seg->cornerpointlast1.longitude, &vec, 1.0); win = glhProjectf (vec, mvmatrix, projmatrix, width, height); seg->winvecend3 = win; LonLat2PointRad((float)seg->cornerpointlast2.latitude, (float)seg->cornerpointlast2.longitude, &vec, 1.0); win = glhProjectf (vec, mvmatrix, projmatrix, width, height); seg->winvecend4 = win; win = glhProjectf (seg->vec1, mvmatrix, projmatrix, width, height); seg->winvec1 = win; win = glhProjectf (seg->vec2, mvmatrix, projmatrix, width, height); seg->winvec2 = win; }