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


C++ Point2D::getMagnitude方法代码示例

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


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

示例1: generateLineObservations

void ObservationGenerator::generateLineObservations() {
    getSelf(gtSelf,obsSelf,player_);
    int seenLines = 0;

    for (int i = WO_OPP_GOAL_LINE; i <= WO_BOTTOM_SIDE_LINE; i++) {
        if (seenLines >= 4) break;
        WorldObject& truthWO = gt_object_->objects_[i];

        Line2D visionLine(gtSelf.loc, gtSelf.orientation);
        Point2D point = truthWO.lineLoc.getSegmentIntersection(visionLine);
        int idx = WO_UNKNOWN_FIELD_LINE_1+seenLines;
        if(i == WO_CENTER_LINE) idx = WO_CENTER_LINE;
        auto& obsWO = obs_object_->objects_[idx];
        float bearing = gtSelf.loc.getBearingTo(point, gtSelf.orientation);
        float distance = gtSelf.loc.getDistanceTo(point);
        float pan = joint_->values_[HeadPan];
        if (fabs(pan - bearing) > FOVx/2.0)
            continue;

        float missedObsRate = 1.0/3.0;
        float randPct = rand_.sampleU();
        // see lines up to 2.5 m
        if (randPct > (missedObsRate * MISSED_OBS_FACTOR) && distance < 2500) {
            // seen
            seenLines++;

            float maxleft = gtSelf.orientation + pan + FOVx/2;
            float maxright = gtSelf.orientation + pan - FOVx/2;
            LineSegment vline = truthWO.lineLoc.getVisiblePortion(gtSelf.loc, gtSelf.orientation + pan, FOVx);
            vline = vline.globalToRelative(gtSelf.loc, gtSelf.orientation);

            float xnoise = rand_.sampleU(.95,1.05);
            float ynoise = rand_.sampleU(.95,1.05);
            float tnoise = rand_.sampleU(-10 * DEG_T_RAD, 10 * DEG_T_RAD);
            vline.start.x *= xnoise;
            vline.end.x *= xnoise;
            vline.start.y *= ynoise;
            vline.end.y *= ynoise;
            vline.computeCenter();
            obsWO.visionPt1 = vline.start;
            obsWO.visionPt2 = vline.end;
            obsWO.visionLine = vline;
            Point2D robot(0,0);
            Point2D closest = vline.getPointOnSegmentClosestTo(robot);
            obsWO.visionDistance = closest.getMagnitude();
            obsWO.visionBearing = closest.getDirection();
            obsWO.visionConfidence = 1.0;
            float diff = joint_->values_[HeadPan] - bearing;
            obsWO.imageCenterX = iparams_.width/2.0 + (diff / (FOVx/2.0) * iparams_.width/2.0);
            obsWO.imageCenterY = iparams_.height/2.0;
            obsWO.seen = true;


            point = point.globalToRelative(gtSelf.loc, gtSelf.orientation);
        } // line was seen with random prob
    } // line loop
}
开发者ID:ypei92,项目名称:cs393r_autonomous_robot_code,代码行数:57,代码来源:ObservationGenerator.cpp


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