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


C# Quaternion.Normalise方法代码示例

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


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

示例1: QuaternionNormaliseTest

        public void QuaternionNormaliseTest()
        {
            var a = new Quaternion(3.0f, 4.0f, 3.0f, 1.0f);
            var expectedResult = new Quaternion(0.5070925f, 0.6761234f, 0.5070925f, 0.1690308f);

            a.Normalise();

            Assert.True(a.Equals(expectedResult, 1e-3f));
        }
开发者ID:richardhallett,项目名称:nml,代码行数:9,代码来源:QuaternionTests.cs

示例2: QuaternionIsNormaliseTest

        public void QuaternionIsNormaliseTest()
        {
            var a = new Quaternion(3.0f, 4.0f, 3.0f, 1.0f);
            var expectedResult = true;

            a.Normalise();

            var r = a.IsNormalised;

            Assert.Equal<bool>(expectedResult, r);
        }    
开发者ID:richardhallett,项目名称:nml,代码行数:11,代码来源:QuaternionTests.cs

示例3: addQuats

 private Quaternion addQuats(Quaternion q1, Quaternion q2)
 {
     float x = q1.x + q2.x;
     float y = q1.y + q2.y;
     float z = q1.z + q2.z;
     float w = q1.w + q2.w;
     Quaternion q = new Quaternion(w, x, y, z);
     chat(q.Normalise().ToString());
     return q;
 }
开发者ID:andyhebear,项目名称:extramegablob,代码行数:10,代码来源:Players_Client.cs

示例4: process

        //    *
        //	Run image manipulation
        //	\return Pointer to image buffer which has been set in the constructor.
        //	
        public override TextureBuffer process() {
            Quaternion qion = new Quaternion();
            float sum = 0f;
            Vector3 q = new Vector3();

            int w = (int)mBuffer.getWidth();
            int h = (int)mBuffer.getHeight();
            Quaternion rotation = new Quaternion(mW, mAxis);

            if (mParam != null && (mParam.getWidth() < w || mParam.getHeight() < h))
                return mBuffer;

            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    ColourValue pixel = mBuffer.getPixel(x, y);
                    Quaternion v = new Quaternion(0.0f, ((pixel.r * 255.0f) - 127.5f) / 127.5f, ((pixel.b * 255.0f) - 127.5f) / 127.5f, ((pixel.g * 255.0f) - 127.5f) / 127.5f);

                    if (mParam != null) {
                        pixel = mParam.getPixel(x, y);
                        switch (mCompensation) {
                            case ABNORMALS_COMPENSATION.COMPENSATION_NORMAL:
                                qion = new Quaternion(0.0f, (pixel.r * 255.0f) - 127.5f, (pixel.b * 255.0f) - 127.5f, (pixel.g * 255.0f) - 127.5f);
                                v = v * (float)(1 - mSensitivity);
                                v = v + qion * ((float)mSensitivity / 127.5f);
                                break;

                            case ABNORMALS_COMPENSATION.COMPENSATION_HEIGHT:
                                sum = ((pixel.r + pixel.g + pixel.b) / 3.0f) * 255.0f;
                                qion = new Quaternion(new Radian(Math.TWO_PI * sum / 765.0f * mSensitivity), new Vector3(0.0f, 1.0f, 0.0f));
                                rotation = rotation * qion;
                                break;

                            case ABNORMALS_COMPENSATION.COMPENSATION_QUATERNION:
                                q = new Vector3((pixel.r * 255.0f) - 127.5f, (pixel.b * 255.0f) - 127.5f, (pixel.g * 255.0f) - 127.5f);
                                qion = new Quaternion(new Radian(2.0f / 255.0f * Math.PI * pixel.a * mSensitivity), q);
                                rotation = rotation * qion;
                                break;
                        }
                    }

                    v = rotation * v * rotation.Inverse();
                    float norm = v.Normalise();

                    if (mMirror == ABNORMALS_MIRROR.MIRROR_X_YZ || mMirror == ABNORMALS_MIRROR.MIRROR_X_Y_Z)
                        mBuffer.setRed(x, y, (1.0f - v.x * 0.5f + 0.5f));
                    else
                        mBuffer.setRed(x, y, (v.x * 0.5f + 0.5f));
                    if (mMirror == ABNORMALS_MIRROR.MIRROR_Y_XZ || mMirror == ABNORMALS_MIRROR.MIRROR_X_Y_Z)
                        mBuffer.setGreen(x, y, (1.0f - v.z * 0.5f + 0.5f));
                    else
                        mBuffer.setGreen(x, y, (v.z * 0.5f + 0.5f));
                    mBuffer.setBlue(x, y, (v.y * 0.5f + 0.5f));
                }
            }

            Utils.log("Modify texture with abnormals filter");
            return mBuffer;
        }
开发者ID:andyhebear,项目名称:mogre-procedural,代码行数:62,代码来源:ProceduralTextureModifiers.cs

示例5: LookAt

        public void LookAt(Vector3 vector)
        {
            Vector3 direction = vector - Position;
            direction.Normalise();
            if(direction == Vector3.ZERO) return;

            var forward = direction;
            forward.Normalise();
            var right = direction.CrossProduct(Vector3.UNIT_Y);
            right.Normalise();
            var up = right.CrossProduct(forward);
            up.Normalise();
            var quaternion = new Quaternion(right, up, -forward);
            quaternion.Normalise();
            Orientation = quaternion;
        }
开发者ID:crescent,项目名称:SubmarineSim3D,代码行数:16,代码来源:SimNode.cs


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