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


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

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


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

示例1: updateFrom

void Robot::updateFrom(tf::TransformListener *tfListener) {
	using namespace Ogre;
	static tf::StampedTransform baseTF;
	static Vector3 translation = Vector3::ZERO;
	static Quaternion orientation = Quaternion::IDENTITY;
	static Quaternion qRot = Quaternion(-sqrt(0.5), 0.0f, sqrt(0.5), 0.0f)*Quaternion(-sqrt(0.5), sqrt(0.5), 0.0f, 0.0f);
	static Quaternion qYn90 = Quaternion(Degree(90), Vector3::NEGATIVE_UNIT_Y);
	static tfScalar yaw,pitch,roll;
	static Matrix3 mRot;
	
	try {
		tfListener->lookupTransform("map","base_footprint",ros::Time(0), baseTF);
		
		translation.x = baseTF.getOrigin().x();
		translation.y = baseTF.getOrigin().y();
		translation.z = baseTF.getOrigin().z();
		translation = qRot*translation + Vector3(0.0f, 1.0f, 0.0f);
		baseTF.getBasis().getEulerYPR(yaw,pitch,roll);
		mRot.FromEulerAnglesYXZ(Radian(yaw),Radian(0.0f),Radian(0.0f));
		orientation.FromRotationMatrix(mRot);
		orientation = qYn90*orientation;
		
		robot->setPosition(translation);
		robot->setOrientation(orientation);
		
	} catch (tf::TransformException ex){
		ROS_ERROR("%s",ex.what());
	}
}
开发者ID:RaresAmbrus,项目名称:roculus,代码行数:29,代码来源:Robot.cpp

示例2: PositionChanged

void RoadPositionSystem::PositionChanged(GameObject* object) {
    auto road = object->GetComponent<Road>();
    auto roadPosition = object->GetComponent<RoadPosition>();
    auto transform = object->GetComponent<Transform>();

    float width;
    Matrix4x4 world = road->GetWorld(roadPosition->Position(), width);

    transform->Position = world.TransformPosition(0);

    Quaternion rot;
    rot.FromRotationMatrix(world);
    
    transform->Rotation = rot;
}
开发者ID:JeppeNielsen,项目名称:PocketEngine,代码行数:15,代码来源:RoadPosition.cpp

示例3: LoadRotation

Quaternion OgreMaxUtilities::LoadRotation(const TiXmlElement* objectElement)
{
    Quaternion rotation = Quaternion::IDENTITY;

    if (objectElement->Attribute("qx") != 0)
    {
        //The rotation is specified as a quaternion
        rotation.x = GetRealAttribute(objectElement, "qx", 0);
        rotation.y = GetRealAttribute(objectElement, "qy", 0);
        rotation.z = GetRealAttribute(objectElement, "qz", 0);
        rotation.w = GetRealAttribute(objectElement, "qw", 0);
    }
    else if (objectElement->Attribute("axisX") != 0)
    {
        //The rotation is specified as an axis and angle
        Real angle = GetRealAttribute(objectElement, "angle", 0);

        Vector3 axis;
        axis.x = GetRealAttribute(objectElement, "axisX", 0);
        axis.y = GetRealAttribute(objectElement, "axisY", 0);
        axis.z = GetRealAttribute(objectElement, "axisZ", 0);

        //Convert the angle and axis into the rotation quaternion
        rotation.FromAngleAxis(Radian(angle), axis);
    }
    else if (objectElement->Attribute("angleX") != 0)
    {
        //Assume the rotation is specified as three Euler angles
        Vector3 euler;
        euler.x = GetRealAttribute(objectElement, "angleX", 0);
        euler.y = GetRealAttribute(objectElement, "angleY", 0);
        euler.z = GetRealAttribute(objectElement, "angleZ", 0);
        String order = GetStringAttribute(objectElement, "order");

        //Convert Euler angles to a matrix
        Matrix3 rotationMatrix;
        if (order.length() < 2)
            rotationMatrix.FromEulerAnglesXYZ(Radian(euler.x), Radian(euler.y), Radian(euler.z));
        else
        {
            if (order[0] == 'x')
            {
                if (order[1] == 'y')
                    rotationMatrix.FromEulerAnglesXYZ(Radian(euler.x), Radian(euler.y), Radian(euler.z));
                else
                    rotationMatrix.FromEulerAnglesXZY(Radian(euler.x), Radian(euler.y), Radian(euler.z));
            }
            else if (order[0] == 'y')
            {
                if (order[1] == 'x')
                    rotationMatrix.FromEulerAnglesYXZ(Radian(euler.x), Radian(euler.y), Radian(euler.z));
                else
                    rotationMatrix.FromEulerAnglesYZX(Radian(euler.x), Radian(euler.y), Radian(euler.z));
            }
            else
            {
                if (order[1] == 'x')
                    rotationMatrix.FromEulerAnglesZXY(Radian(euler.x), Radian(euler.y), Radian(euler.z));
                else
                    rotationMatrix.FromEulerAnglesZYX(Radian(euler.x), Radian(euler.y), Radian(euler.z));
            }
        }

        //Convert the matrix into the rotation quaternion
        rotation.FromRotationMatrix(rotationMatrix);
    }
    
    return rotation;
}
开发者ID:Gachuk,项目名称:Hardwar,代码行数:69,代码来源:OgreMaxUtilities.cpp


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