SkyObject::UID StarObject::getUID() const { // mag takes 10 bit SkyObject::UID m = mag()*10; if( m < 0 ) m = 0; // Both RA & dec fits in 24-bits SkyObject::UID ra = ra0().Degrees() * 36000; SkyObject::UID dec = (ra0().Degrees()+91) * 36000; Q_ASSERT("Magnitude is expected to fit into 10bits" && m>=0 && m<(1<<10)); Q_ASSERT("RA should fit into 24bits" && ra>=0 && ra <(1<<24)); Q_ASSERT("Dec should fit into 24bits" && dec>=0 && dec<(1<<24)); return (SkyObject::UID_STAR << 60) | (m << 48) | (ra << 24) | dec; }
void assign_test() { std::cout << "With U = [" << nt2::type_id<U>() << "]\n"; static const std::size_t N = 11; nt2::table<T> a0(nt2::of_size(N)); nt2::table< std::complex<T> > a1(nt2::of_size(N)); for(std::size_t i=0; i!=N; ++i) { a0(i+1) = T(roll<U>()); a1(i+1) = a0(i+1); } boost::proto::display_expr( nt2::cast<std::complex<U> >(a0) ); nt2::table<std::complex<U> > ra0 = nt2::cast< std::complex<U> >(a0); for(std::size_t i=0; i!= N; ++i) { std::cout << a0(i+1) << "\n"; NT2_TEST_EQUAL( ra0(i+1), nt2::cast(a0(i+1), nt2::meta::as_< std::complex<U> >()) ); } boost::proto::display_expr( nt2::cast<std::complex<U> >(a1) ); nt2::table<std::complex<U> > ra1 = nt2::cast< std::complex<U> >(a1); for(std::size_t i=0; i!= N; ++i) { std::cout << a1(i+1) << "\n"; NT2_TEST_EQUAL( ra1(i+1), nt2::cast(a1(i+1), nt2::meta::as_< std::complex<U> >()) ); } };
void StarObject::getIndexCoords( KSNumbers *num, double *ra, double *dec ) { // Old, Incorrect Proper motion Computation. We retain this in a // comment because we might want to use it to come up with a // linear approximation that's faster. // double dra = pmRA() * num->julianMillenia() / ( cos( dec0().radians() ) * 3600.0 ); // double ddec = pmDec() * num->julianMillenia() / 3600.0; // Proper Motion Correction should be implemented as motion along a great // circle passing through the given (ra0, dec0) in a direction of // atan2( pmRA(), pmDec() ) to an angular distance given by the Magnitude of // PM times the number of Julian millenia since J2000.0 if( pmMagnitudeSquared() * num->julianMillenia() * num->julianMillenia() < 1. ) { // Ignore corrections *ra = ra0().Degrees(); *dec = dec0().Degrees(); return; } double pm = pmMagnitude() * num->julianMillenia(); // Proper Motion in arcseconds double dir0 = ( pm > 0 ) ? atan2( pmRA(), pmDec() ) : atan2( -pmRA(), -pmDec() ); // Bearing, in radian ( pm < 0 ) && ( pm = -pm ); double dst = pm * M_PI / ( 180.0 * 3600.0 ); // double phi = M_PI / 2.0 - dec0().radians(); dms lat1, dtheta; lat1.setRadians( asin( dec0().sin() * cos( dst ) + dec0().cos() * sin( dst ) * cos( dir0 ) ) ); dtheta.setRadians( atan2( sin( dir0 ) * sin( dst ) * dec0().cos(), cos( dst ) - dec0().sin() * lat1.sin() ) ); // Using dms instead, to ensure that the numbers are in the right range. dms finalRA( ra0().Degrees() + dtheta.Degrees() ); *ra = finalRA.Degrees(); *dec = lat1.Degrees(); // *ra = ra0().Degrees() + dra; // *dec = dec0().Degrees() + ddec; }
SkyObject::UID DeepSkyObject::getUID() const { // mag takes 10 bit SkyObject::UID m = mag()*10; if( m < 0 ) m = 0; // Both RA & dec fits in 24-bits SkyObject::UID ra = ra0().Degrees() * 36000; SkyObject::UID dec = (ra0().Degrees()+91) * 36000; assert("Magnitude is expected to fit into 10bits" && m>=0 && m<(1<<10)); assert("RA should fit into 24bits" && ra>=0 && ra <(1<<24)); assert("Dec should fit into 24bits" && dec>=0 && dec<(1<<24)); // Choose kind of SkyObject::UID kind = type() == SkyObject::GALAXY ? SkyObject::UID_GALAXY : SkyObject::UID_DEEPSKY; return (kind << 60) | (m << 48) | (ra << 24) | dec; }
void StarObject::updateCoords( KSNumbers *num, bool , const dms*, const dms*, bool ) { //Correct for proper motion of stars. Determine RA and Dec offsets. //Proper motion is given im milliarcsec per year by the pmRA() and pmDec() functions. //That is numerically identical to the number of arcsec per millenium, so multiply by //KSNumbers::julianMillenia() to find the offsets in arcsec. // Correction: The method below computes the proper motion before the // precession. If we precessed first then the direction of the proper // motion correction would depend on how far we've precessed. -jbb double saveRA = ra0().Hours(); double saveDec = dec0().Degrees(); double newRA, newDec; getIndexCoords( num, &newRA, &newDec ); newRA /= 15.0; // getIndexCoords returns in Degrees, while we want the RA in Hours setRA0( newRA ); setDec0( newDec ); SkyPoint::updateCoords( num ); setRA0( saveRA ); setDec0( saveDec ); }