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


C# Quaternion.GetMatrix方法代码示例

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


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

示例1: TestGetMatrix

        public void TestGetMatrix()
        {
            TK.Quaternion tkQ = TK.Quaternion.FromAxisAngle(new TK.Vector3(.25f, .5f, 0.0f), TK.MathHelper.PiOver2);
            Quaternion q = new Quaternion(tkQ.W, tkQ.X, tkQ.Y, tkQ.Z);

            TK.Matrix4 tkM = TK.Matrix4.CreateFromAxisAngle(new TK.Vector3(.25f, .5f, 0.0f), TK.MathHelper.PiOver2);
            Matrix4x4 m = q.GetMatrix();

            TestHelper.AssertEquals(tkM, m, "Testing GetMatrix");
        }
开发者ID:hasanabb,项目名称:assimp-net,代码行数:10,代码来源:QuaternionTestFixture.cs

示例2: TestConversions

        private void TestConversions()
        {
            Matrix4 eulmtx = Matrix4.RotateEuler(Yaw, Pitch, Roll);
            Vector3 axis;
            float angle;
            Matrix4.GetAxisAngle(eulmtx, out axis, out angle);

            Quaternion eulerq = new Quaternion(Yaw, Pitch, Roll);
            Quaternion axisq = new Quaternion(angle, axis);
            Quaternion compound = (new Quaternion(Roll, new Vector3(0, 0, 1))) * (new Quaternion(Pitch, new Vector3(1, 0, 0))) * (new Quaternion(Yaw, new Vector3(0, 1, 0)));

            DXQuat dxeuler = DXQuat.RotationAxis(new Microsoft.DirectX.Vector3(axis.x, axis.y, axis.z), angle);
            DXQuat dxaxis = DXQuat.RotationYawPitchRoll(Yaw, Pitch, Roll);

            Matrix4 fromeq = eulerq.GetMatrix();
            Matrix4 fromaq = axisq.GetMatrix();
            Matrix4 fromcq = compound.GetMatrix();

            DXMatrix dxcntrlmtx = DXMatrix.RotationYawPitchRoll(Yaw, Pitch, Roll);
            DXMatrix dxeulmtx = DXMatrix.RotationQuaternion(dxeuler);
            DXMatrix dxaxismtx = DXMatrix.RotationQuaternion(dxaxis);
        }
开发者ID:Innabus,项目名称:Innabus,代码行数:22,代码来源:QuatRegression.cs

示例3: localRotation

 public static void localRotation(Quaternion rotStart, ref Quaternion rotEnd)
 {
     rotStart.GetMatrix().Inverse();
     rotEnd *= rotStart;
 }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:5,代码来源:AssimpUtil.cs

示例4: TestToFromQuaternion

        public void TestToFromQuaternion()
        {
            Vector3D axis = new Vector3D(.25f, .5f, 0.0f);
            axis.Normalize();

            float angle = (float) Math.PI;

            Quaternion q = new Quaternion(axis, angle);
            Matrix3x3 m = q.GetMatrix();
            Quaternion q2 = new Quaternion(m);

            TestHelper.AssertEquals(q.X, q.Y, q.Z, q.W, q2, "Testing Quaternion->Matrix->Quaternion");
        }
开发者ID:dkushner,项目名称:Assimp-Net,代码行数:13,代码来源:Matrix3x3TestFixture.cs

示例5: Evaluate

        public void Evaluate( float pTime, Dictionary<string,cBone> bones)
        {
            pTime *= TicksPerSecond;

            float time = 0.0f;
            if( Duration > 0.0)
                time = pTime % Duration;

            // calculate the transformations for each animation channel
            for(int a = 0; a < Channels.Count(); a++)
            {
                cAnimationChannel channel = Channels[a];
                cBone bonenode;
                bool found = bones.TryGetValue(channel.Name, out bonenode);
                //std::map<std::string, cBone*>::iterator bonenode = bones.find(channel->Name);

                if(!found)
                {
                    Console.Write("Couldn't find bone");
                    continue;
                }
                // ******** Position *****
                Vector3D presentPosition = new Vector3D(0, 0, 0);
                if(channel.mPositionKeys.Count > 0){
                    // Look for present frame number. Search from last position if time is after the last time, else from beginning
                    // Should be much quicker than always looking from start for the average use case.
                    int frame = (time >= mLastTime) ? mLastPositions[a].Item1 : 0;
                    while( frame < channel.mPositionKeys.Count() - 1)
                    {
                        if(time < channel.mPositionKeys[frame+1].Time)
                        {
                            break;
                        }
                        frame++;
                    }
                    // interpolate between this frame's value and next frame's value
                    int nextFrame = (frame + 1) % channel.mPositionKeys.Count();

                    VectorKey key = channel.mPositionKeys[frame];
                    VectorKey nextKey = channel.mPositionKeys[nextFrame];
                    double diffTime = nextKey.Time - key.Time;
                    if( diffTime < 0.0)
                        diffTime += Duration;
                    if( diffTime > 0)
                    {
                        float factor = (float)((time - key.Time) / diffTime);
                        presentPosition = key.Value + (nextKey.Value - key.Value) * factor;
                    }
                    else
                    {
                        presentPosition = key.Value;
                    }
                    mLastPositions[a] = new Tuple<int,int,int>(frame, mLastPositions[a].Item2, mLastPositions[a].Item3);
                }
                // ******** Rotation *********
                Quaternion presentRotation = new Quaternion(1, 0, 0, 0);
                if(channel.mRotationKeys.Count() > 0)
                {
                    int frame = (time >= mLastTime) ? mLastPositions[a].Item2 : 0;
                    while( frame < channel.mRotationKeys.Count()  - 1)
                    {
                        if( time < channel.mRotationKeys[frame+1].Time)
                            break;
                        frame++;
                    }

                    // interpolate between this frame's value and next frame's value
                    int nextFrame = (frame + 1) % channel.mRotationKeys.Count();

                    QuaternionKey key = channel.mRotationKeys[frame];
                    QuaternionKey nextKey = channel.mRotationKeys[nextFrame];
                    double diffTime = nextKey.Time - key.Time;
                    if( diffTime < 0.0) diffTime += Duration;
                    if( diffTime > 0)
                    {
                        float factor = (float)((time - key.Time) / diffTime);
                        //this next line might be wrong (written awake for 20 hours), but I chanced it
                        presentRotation *= Quaternion.Slerp(key.Value, nextKey.Value, factor);
                    }
                    else presentRotation = key.Value;
                    mLastPositions[a] = new Tuple<int,int,int>(mLastPositions[a].Item1, frame, mLastPositions[a].Item3);
                }

                // ******** Scaling **********
                Vector3D presentScaling = new Vector3D(1, 1, 1);
                if(channel.mScalingKeys.Count() > 0)
                {
                    int frame = (time >= mLastTime) ? mLastPositions[a].Item3 : 0;
                    while( frame < channel.mScalingKeys.Count() - 1){
                        if( time < channel.mScalingKeys[frame+1].Time)
                            break;
                        frame++;
                    }
                    presentScaling = channel.mScalingKeys[frame].Value;
                    mLastPositions[a] = new Tuple<int,int,int>(mLastPositions[a].Item1, mLastPositions[a].Item2, frame);
                }

                Matrix4x4 mat = new Matrix4x4(presentRotation.GetMatrix());

                mat.A1 *= presentScaling.X; mat.B1 *= presentScaling.X; mat.C1 *= presentScaling.X;
//.........这里部分代码省略.........
开发者ID:EternalEnvy,项目名称:SmackBrosClient,代码行数:101,代码来源:AnimationLoader.cs


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