当前位置: 首页>>代码示例>>C++>>正文


C++ SkyPoint::angularDistanceTo方法代码示例

本文整理汇总了C++中SkyPoint::angularDistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C++ SkyPoint::angularDistanceTo方法的具体用法?C++ SkyPoint::angularDistanceTo怎么用?C++ SkyPoint::angularDistanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkyPoint的用法示例。


在下文中一共展示了SkyPoint::angularDistanceTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: kDebug

QList<const StarObject *> StarHopper::computePath( const SkyPoint &src, const SkyPoint &dest, float fov_, float maglim_ ) {

fov = fov_;
maglim = maglim_;
start = &src;
end = &dest;

came_from.clear();
result_path.clear();


// Implements the A* search algorithm

QList<SkyPoint const *> cSet;
QList<SkyPoint const *> oSet;
QHash<SkyPoint const *, double> g_score;
QHash<SkyPoint const *, double> f_score;
QHash<SkyPoint const *, double> h_score;

kDebug() << "StarHopper is trying to compute a path from source: " << src.ra().toHMSString() << src.dec().toDMSString() << " to destination: " << dest.ra().toHMSString() << dest.dec().toDMSString() << "; a starhop of " << src.angularDistanceTo( &dest ).Degrees() << " degrees!";

oSet.append( &src );
g_score[ &src ] = 0;
h_score[ &src ] = src.angularDistanceTo( &dest ).Degrees()/fov;
f_score[ &src ] = h_score[ &src ];

while( !oSet.isEmpty() ) {
    kDebug() << "Next step";
    // Find the node with the lowest f_score value
    SkyPoint const *curr_node = NULL;
    double lowfscore = 1.0e8;
    foreach( const SkyPoint *sp, oSet ) {
        if( f_score[ sp ] < lowfscore ) {
            lowfscore = f_score[ sp ];
            curr_node = sp;
        }
    }
    kDebug() << "Lowest fscore (vertex distance-plus-cost score) is " << lowfscore << " with coords: " << curr_node->ra().toHMSString() << curr_node->dec().toDMSString() << ". Considering this node now.";
    if( curr_node == &dest || (curr_node != &src && h_score[ curr_node ] < 0.5) ) {
        // We are at destination
        reconstructPath( came_from[ curr_node ] );
        kDebug() << "We've arrived at the destination! Yay! Result path count: " << result_path.count();

        // Just a test -- try to print out useful instructions to the debug console. Once we make star hopper unexperimental, we should move this to some sort of a display
        kDebug() << "Star Hopping Directions: ";
        const SkyPoint *prevHop = start;
        foreach( const StarObject *hopStar, result_path ) {
            QString direction;
            double pa; // should be 0 to 2pi

            dms angDist = prevHop->angularDistanceTo( hopStar, &pa );

            dms dmsPA;
            dmsPA.setRadians( pa );
            direction = KSUtils::toDirectionString( dmsPA );

            kDebug() << "  Slew " << angDist.Degrees() << " degrees " << direction << " to find a " << hopStar->spchar() << " star of mag " << hopStar->mag();
            prevHop = hopStar;
        }
        kDebug() << "  The destination is within a field-of-view";

        return result_path;
    }
开发者ID:mohanaprasad1994,项目名称:kstars-hackfest,代码行数:63,代码来源:starhopper.cpp


注:本文中的SkyPoint::angularDistanceTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。