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


C++ Transform3D::reset方法代码示例

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


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

示例1: unit_test_EstimateSimilarityTransformation3D


//.........这里部分代码省略.........
            source_points1.push_back(source_point4);

            target_points1.clear();
            target_points1.push_back(target_point1);
            target_points1.push_back(target_point2);
            target_points1.push_back(target_point3);
            target_points1.push_back(target_point4);

            estimateSimilarityTransformation.setSourcePoints(source_points1);
            estimateSimilarityTransformation.setTargetPoints(target_points1);
        STOP_TEST


        START_TEST
            estimateSimilarityTransformation.compute();
        STOP_TEST


    SUBHEADING(getTransformationMatrix())

        START_TEST
            assert(estimateSimilarityTransformation.getTransformationMatrix().isApprox(transform.getTransformationMatrix()));
        STOP_TEST


    SUBHEADING(getRotationMatrix())


        START_TEST
            assert(estimateSimilarityTransformation.getRotationMatrix().isApprox(transform.getTransformationMatrix().block(0, 0, 3, 3)));
        STOP_TEST


    SUBHEADING(getTranslationVector())


        START_TEST
            assert(estimateSimilarityTransformation.getTranslationVector().isApprox(transform.getTransformationMatrix().block(0, 3, 3, 1)));
        STOP_TEST


    SUBHEADING(getRMS())


        START_TEST
            assert(estimateSimilarityTransformation.getRMS() < 1e-10);
        STOP_TEST


    SUBHEADING(getScalingFactor())


        START_TEST
            assert(isEqual(estimateSimilarityTransformation.getScalingFactor(), 2.0));
        STOP_TEST


    SUBHEADING(Handedness)


        START_TEST
            transform.reset().rotateZ(1.0).rotateY(2.0).scale(2, 2, 2).translate(1, 2, 3); // arbitrary rotation in 3D

            // generate some test points

            vector<Coordinate<double> > source_points;

            source_points.push_back(Coordinate<double>( 1,  1, 0));
            source_points.push_back(Coordinate<double>(-1, -1, 0));
            source_points.push_back(Coordinate<double>( 2,  0, 0));

            vector<Coordinate<double> > target_points;

            target_points.push_back(transform * Coordinate<double>( 1,  1, 0));
            target_points.push_back(transform * Coordinate<double>(-1, -1, 0));
            target_points.push_back(transform * Coordinate<double>( 2,  0, 0) + Coordinate<double>(0, 0, 1e-15)); // leads to a left-handed coordinate system

            // estimate the transformation

            EstimateSimilarityTransformation estimator(source_points, target_points);

            estimator.compute();

            assert(estimator.getTransformationMatrix().determinant() > 0); // right-handed coordinate system?

            // second test for right-handness (generate new points along the z-axis and ...)

            Coordinate<double> s1 = Coordinate<double>( 2,  5, 1);
            Coordinate<double> s2 = Coordinate<double>(-3,  2, 1);

            Coordinate<double> t1 = transform * Coordinate<double>( 2,  5, 1);
            Coordinate<double> t2 = transform * Coordinate<double>(-3,  2, 1);

            Transform3D<double> transformator(estimator.getTransformationMatrix());

            double residual = (transformator * s1 - t1).squaredNorm() + (transformator * s2 - t2).squaredNorm();

            assert(residual < 1e-15);
        STOP_TEST
}
开发者ID:RWTHmediTEC,项目名称:TRTK,代码行数:101,代码来源:unit_test_EstimateSimilarityTransformation3D.cpp


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