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


C++ Point3::normalizeXY方法代码示例

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


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

示例1: visitPointModel

void ScenarioRenderer::visitPointModel(PointModel &pointModel) {
    Lock l(m_scenarioRendererMutex);
    if (m_renderer != NULL) {
        if ( (pointModel.getLane() != NULL) && (pointModel.getLane()->getRoad() != NULL) && (pointModel.getLane()->getRoad()->getLayer() != NULL) ) {
            const vector<IDVertex3> &listOfVertices = pointModel.getListOfIdentifiableVertices();
            const uint32_t SIZE = listOfVertices.size();
            if (SIZE > 1) {
                m_renderer->beginPainting();
                for (uint32_t i = 0; i < (SIZE-1); i++) {
                    // Get to adjacent vertices, determine direction, construct orthogonal direction
                    Point3 ptA = listOfVertices.at(i);
                    ptA.setZ(pointModel.getLane()->getRoad()->getLayer()->getHeight());

                    Point3 ptB = listOfVertices.at(i+1);
                    ptB.setZ(pointModel.getLane()->getRoad()->getLayer()->getHeight());

                    // Label Waypoints.
                    stringstream namePtA;
                    namePtA << pointModel.getLane()->getRoad()->getLayer()->getID() << "." << pointModel.getLane()->getRoad()->getID() << "." << pointModel.getLane()->getID() << "." << listOfVertices.at(i).getID();
                    m_renderer->setColor(Point3(0.7, 0.7, 0.7));
                    m_renderer->drawText(ptA, namePtA.str());

                    stringstream namePtB;
                    namePtB << pointModel.getLane()->getRoad()->getLayer()->getID() << "." << pointModel.getLane()->getRoad()->getID() << "." << pointModel.getLane()->getID() << "." << listOfVertices.at(i+1).getID();
                    m_renderer->setColor(Point3(0.7, 0.7, 0.7));
                    m_renderer->drawText(ptB, namePtB.str());

                    m_renderer->setColor(Point3(1, 0, 0));
                    m_renderer->setPointWidth(5);
                    m_renderer->drawPoint(ptA);
                    m_renderer->drawPoint(ptB);

                    Point3 colorSkeleton(0.2, 0.2, 0.2);
                    m_renderer->setColor(colorSkeleton);
                    m_renderer->setLineWidth(1);
                    m_renderer->drawLine(ptA, ptB);

                    const double halfWidth = pointModel.getLaneAttribute().getWidth() / 2.0;
                    if (halfWidth > 1) {
                        Point3 orthonormalDirection = (ptB - ptA);
                        orthonormalDirection.normalizeXY();
                        orthonormalDirection.setZ(0);
                        orthonormalDirection.rotateZ(cartesian::Constants::PI/2.0);

                        Point3 colorLeftMarking;
                        switch (pointModel.getLaneAttribute().getLeftLaneMarking()) {
                        case LaneAttribute::SOLID_YELLOW:
                        case LaneAttribute::DOUBLE_YELLOW:
                            colorLeftMarking = Point3(1, 1, 0);
                            break;

                        case LaneAttribute::BROKEN_WHITE:
                        case LaneAttribute::SOLID_WHITE:
                            colorLeftMarking = Point3(1, 1, 1);
                            break;

                        case LaneAttribute::UNDEFINED:
                        case LaneAttribute::CROSSWALK:
                            colorLeftMarking = Point3(0.3, 0.3, 0.3);
                            break;
                        }
                        Point3 leftLanePtA = ptA + (orthonormalDirection * halfWidth);
                        Point3 leftLanePtB = ptB + (orthonormalDirection * halfWidth);

                        m_renderer->setColor(colorLeftMarking);
                        m_renderer->setLineWidth(5);
                        m_renderer->drawLine(leftLanePtA, leftLanePtB);

                        // Draw right lane marking.
                        Point3 colorRightMarking;
                        switch (pointModel.getLaneAttribute().getRightLaneMarking()) {
                        case LaneAttribute::SOLID_YELLOW:
                        case LaneAttribute::DOUBLE_YELLOW:
                            colorRightMarking = Point3(1, 1, 0);
                            break;

                        case LaneAttribute::BROKEN_WHITE:
                        case LaneAttribute::SOLID_WHITE:
                            colorRightMarking = Point3(1, 1, 1);
                            break;

                        case LaneAttribute::UNDEFINED:
                        case LaneAttribute::CROSSWALK:
                            colorRightMarking = Point3(0.3, 0.3, 0.3);
                            break;
                        }
                        Point3 rightLanePtA = ptA - (orthonormalDirection * halfWidth);
                        Point3 rightLanePtB = ptB - (orthonormalDirection * halfWidth);

                        m_renderer->setColor(colorRightMarking);
                        m_renderer->setLineWidth(5);
                        m_renderer->drawLine(rightLanePtA, rightLanePtB);
                    }
                }
                m_renderer->endPainting();
            }
        }
    }
}
开发者ID:romanimm,项目名称:OpenDaVINCI,代码行数:99,代码来源:ScenarioRenderer.cpp


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