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


C++ Quaternion::setFromTwoVectors方法代码示例

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


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

示例1: planeCoefficients

PlaneExt::PlaneExt(but_plane_detector::Plane<float> plane) : but_plane_detector::Plane<float> (0.0, 0.0, 0.0, 0.0), planeCoefficients(new pcl::ModelCoefficients())
{
	a = plane.a;
	b = plane.b;
	c = plane.c;
	d = plane.d;
	norm = plane.norm;

	// Create a quaternion for rotation into XY plane
	Eigen::Vector3f current(a, b, c);
	Eigen::Vector3f target(0.0, 0.0, 1.0);
	Eigen::Quaternion<float> q;
	q.setFromTwoVectors(current, target);
	planeTransXY = q.toRotationMatrix();

	planeShift = -d;

	color.r = abs(a) / 2.0 + 0.2;
	color.g = abs(b) / 2.0 + 0.2;
	color.b = abs(d) / 5.0;
	color.a = 1.0;

	// Plane coefficients pre-calculation...
	planeCoefficients->values.push_back(a);
	planeCoefficients->values.push_back(b);
	planeCoefficients->values.push_back(c);
	planeCoefficients->values.push_back(d);

}
开发者ID:vstancl,项目名称:srs_public,代码行数:29,代码来源:plane.cpp

示例2: setFromVectors

    inline static void setFromVectors(Rotation_& rot, const Eigen::Matrix<PrimType_, 3, 1>& v1, const Eigen::Matrix<PrimType_, 3, 1>& v2) {
        KINDR_ASSERT_TRUE(std::runtime_error,  v1.norm()*v2.norm() != static_cast<PrimType_>(0.0), "At least one vector has zero length.");

        Eigen::Quaternion<PrimType_> eigenQuat;
        eigenQuat.setFromTwoVectors(v1, v2);
        rot = kindr::rotations::eigen_impl::RotationQuaternion<PrimType_, Usage_>(eigenQuat);
//
//    const PrimType_ angle = acos(v1.dot(v2)/temp);
//    const PrimType_ tol = 1e-3;
//
//    if(0 <= angle && angle < tol) {
//      rot.setIdentity();
//    } else if(M_PI - tol < angle && angle < M_PI + tol) {
//      rot = eigen_impl::AngleAxis<PrimType_, Usage_>(angle, 1, 0, 0);
//    } else {
//      const Eigen::Matrix<PrimType_, 3, 1> axis = (v1.cross(v2)).normalized();
//      rot = eigen_impl::AngleAxis<PrimType_, Usage_>(angle, axis);
//    }
    }
开发者ID:ihmcrobotics,项目名称:ihmc-open-robotics-software,代码行数:19,代码来源:RotationEigen.hpp


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