• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Vector4D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Vector4D的典型用法代码示例。如果您正苦于以下问题:C# Vector4D类的具体用法?C# Vector4D怎么用?C# Vector4D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Vector4D类属于命名空间,在下文中一共展示了Vector4D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Decompose

        public static bool Decompose(Matrix4x4 m, out Vector3D scale, out Vector4D rotationQuaternion, out Vector3D translation)
        {
            SlimDX.Vector3 s;
            SlimDX.Quaternion r;
            SlimDX.Vector3 t;

            if (Matrix4x4ToSlimDXMatrix(m).Decompose(out s, out r, out t))
            {
                scale.x = s.X;
                scale.y = s.Y;
                scale.z = s.Z;
                rotationQuaternion.x = r.X;
                rotationQuaternion.y = r.Y;
                rotationQuaternion.z = r.Z;
                rotationQuaternion.w = r.W;
                translation.x = t.X;
                translation.y = t.Y;
                translation.z = t.Z;

                return true;
            }
            else
            {
                scale = new Vector3D(0);
                rotationQuaternion = new Vector4D(0);
                translation = new Vector3D(0);
                return false;
            }
        }
开发者ID:smakhtin,项目名称:DrawSmooth,代码行数:29,代码来源:SlimDXUtils.cs


示例2: Write

 public void Write(Vector4D value)
 {
     Write(value.X);
     Write(value.Y);
     Write(value.Z);
     Write(value.W);
 }
开发者ID:timdetering,项目名称:Physics2D.Net,代码行数:7,代码来源:MathWriter.cs


示例3: MouseMove

        public override void MouseMove(Vector2D mouseMovePos, EnumMouseButton button)
        {


            base.MouseMove(mouseMovePos, button);

            if (handleIndex == null) return;
            Vector2D p = mouseCurrPos - new Vector2D(projectedCenter.x, projectedCenter.y);
            p.x += 100;
            p.y += 100;
            switch (button)
            {
                case EnumMouseButton.Middle: movingBall.Drag(p); break;
                case EnumMouseButton.Left: movingBall.Drag(p / this.ScaleRatio); break;
                case EnumMouseButton.Right: movingBall.Drag(p); break;
            }
            Matrix4D tran = TransformController.Instance.TransformInverse * movingBall.CreateMatrix().Transpose() * TransformController.Instance.ModelMatrix;

            for (int i = 0; i < handleIndex.Count; i++)
            {
                int j = handleIndex[i];
                Vector4D q = new Vector4D((Vector3D)oldHandlePos[i], 1);
                q = tran * (q - handleCenter) + handleCenter;
                mesh.Vertices[j].Traits.Position.x = q.x;
                mesh.Vertices[j].Traits.Position.y = q.y;
                mesh.Vertices[j].Traits.Position.z = q.z;
            }

            //TriMeshUtil.SetUpNormalVertex(mesh);
            OnChanged(EventArgs.Empty);
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:31,代码来源:ToolMoveSinglePoint.cs


示例4: AdditionOperator

 public void AdditionOperator()
 {
     Vector4D a = new Vector4D(1.0, 2.0, 3.0, 4.0);
       Vector4D b = new Vector4D(2.0, 3.0, 4.0, 5.0);
       Vector4D c = a + b;
       Assert.AreEqual(new Vector4D(3.0, 5.0, 7.0, 9.0), c);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:Vector4DTest.cs


示例5: Normalize

        public void Normalize()
        {
            Vector4D v, n1, n2;
            double magnitude;

            v = new Vector4D(3.0, 4.0, 0.0, 0.0);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0, magnitude, 1e-14);

            v = new Vector4D(3.0, 0.0, 4.0, 0.0);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0, magnitude, 1e-14);

            v = new Vector4D(0.0, 3.0, 4.0, 0.0);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0, magnitude, 1e-14);

            v = new Vector4D(0.0, 0.0, 3.0, 4.0);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0, magnitude, 1e-14);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:33,代码来源:Vector4DTests.cs


示例6: Addition

 public void Addition()
 {
     Vector4D a = new Vector4D(1.0, 2.0, 3.0, 4.0);
       Vector4D b = new Vector4D(2.0, 3.0, 4.0, 5.0);
       Vector4D c = Vector4D.Add(a, b);
       Assert.AreEqual(new Vector4D(3.0, 5.0, 7.0, 9.0), c);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:Vector4DTest.cs


示例7: Construct2

 public void Construct2()
 {
     Vector4D v = new Vector4D(new Vector2D(1.0, 2.0), 3.0, 4.0);
     Assert.AreEqual(1.0, v.X);
     Assert.AreEqual(2.0, v.Y);
     Assert.AreEqual(3.0, v.Z);
     Assert.AreEqual(4.0, v.W);
 }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:8,代码来源:Vector4DTests.cs


示例8: Drag

		public void Drag(Vector2D pt)
		{
			endPt = pt;
			endVec = MapToSphere(pt);

			double epsilon = 1.0e-5;
			Vector3D prep = startVec.Cross(endVec);

			if (prep.Length() > epsilon)
				quat = new Vector4D(prep, startVec.Dot(endVec));
			else
				quat = new Vector4D();
		}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:13,代码来源:Arcball.cs


示例9: MakeRotate

        //from openFrameworks
        private Vector4D MakeRotate(Vector3D from, Vector3D to)
        {
            Vector4D quat = new Vector4D();
            Vector3D sourceVector = from / from.Length;
            Vector3D targetVector = to / to.Length;

            // Now let's get into the real stuff
            // Use "dot product plus one" as test as it can be re-used later on

            double dotProdPlus1 = 1.0 +  sourceVector.dot(targetVector);

            // Check for degenerate case of full u-turn. Use epsilon for detection
            if (dotProdPlus1 < 1e-7) {

                // Get an orthogonal vector of the given vector
                // in a plane with maximum vector coordinates.
                // Then use it as quaternion axis with pi angle
                // Trick is to realize one value at least is >0.6 for a normalized vector.
                if (fabs(sourceVector.x) < 0.6) {
                    const double norm = sqrt(1.0 - sourceVector.x * sourceVector.x);
                    _v.x = 0.0;
                    _v.y = sourceVector.z / norm;
                    _v.z = -sourceVector.y / norm;
                    _v.w = 0.0;
                } else if (fabs(sourceVector.y) < 0.6) {
                    const double norm = sqrt(1.0 - sourceVector.y * sourceVector.y);
                    _v.x = -sourceVector.z / norm;
                    _v.y = 0.0;
                    _v.z = sourceVector.x / norm;
                    _v.w = 0.0;
                } else {
                    const double norm = sqrt(1.0 - sourceVector.z * sourceVector.z);
                    _v.x = sourceVector.y / norm;
                    _v.y = -sourceVector.x / norm;
                    _v.z = 0.0;
                    _v.w = 0.0;
                }
            }

            else {
                // Find the shortest angle quaternion that transforms normalized vectors
                // into one other. Formula is still valid when vectors are colinear
                const double s = sqrt(0.5 * dotProdPlus1);
                const ofVec3f tmp = sourceVector.getCrossed(targetVector) / (2.0 * s);
                _v.x = tmp.x;
                _v.y = tmp.y;
                _v.z = tmp.z;
                _v.w = s;
            }
            return quat;
        }
开发者ID:elliotwoods,项目名称:Screenlab-0x01,代码行数:52,代码来源:QuaternionMakeRotateNode.cs


示例10: BBox2DtoVVVV

        public static Vector4D BBox2DtoVVVV(this PXCMRectI32 pt, Vector2D ImageSize)
        {
            var bbox2d = new Vector4D();

            bbox2d.z = pt.w / (float)ImageSize.x;
            bbox2d.w = pt.h / (float)ImageSize.y;

            bbox2d.x = (pt.x / (float)ImageSize.x * 2.0f - 1.0f) + bbox2d.z;
            bbox2d.y = (1.0f - pt.y / (float)ImageSize.y * 2.0f) - bbox2d.w;

            bbox2d.z *= 2;
            bbox2d.w *= 2;

            return bbox2d;
        }
开发者ID:zeos,项目名称:Somaphone,代码行数:15,代码来源:VectorConverter.cs


示例11: AreEqual

        public void AreEqual()
        {
            double originalEpsilon = Numeric.EpsilonD;
              Numeric.EpsilonD = 1e-8;

              Vector4D u = new Vector4D(1.0, 2.0, 3.0, 4.0);
              Vector4D v = new Vector4D(1.000001, 2.000001, 3.000001, 4.000001);
              Vector4D w = new Vector4D(1.00000001, 2.00000001, 3.00000001, 4.00000001);

              Assert.IsTrue(Vector4D.AreNumericallyEqual(u, u));
              Assert.IsFalse(Vector4D.AreNumericallyEqual(u, v));
              Assert.IsTrue(Vector4D.AreNumericallyEqual(u, w));

              Numeric.EpsilonD = originalEpsilon;
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:15,代码来源:Vector4DTest.cs


示例12: ResolveShadows

 public void ResolveShadows(Image shadowCastersTexture, RenderImage result, Vector2D lightPosition,
                            bool attenuateShadows, Image mask, Vector4D maskProps, Vector4D diffuseColor)
 {
     resolveShadowsEffect.Parameters["AttenuateShadows"].SetValue(attenuateShadows ? 0 : 1);
     resolveShadowsEffect.Parameters["MaskProps"].SetValue(maskProps);
     resolveShadowsEffect.Parameters["DiffuseColor"].SetValue(diffuseColor);
     //Gorgon.CurrentRenderTarget.BlendingMode = BlendingModes.None;
     ExecuteTechnique(shadowCastersTexture, distancesRT, "ComputeDistances");
     ExecuteTechnique(distancesRT.Image, distortRT, "Distort");
     ApplyHorizontalReduction(distortRT, shadowMap);
     ExecuteTechnique(mask, result, "DrawShadows", shadowMap);
     //ExecuteTechnique(shadowsRT.Image, processedShadowsRT, "BlurHorizontally");
     //ExecuteTechnique(processedShadowsRT.Image, result, "BlurVerticallyAndAttenuate");
     Gorgon.CurrentShader = null;
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:15,代码来源:ShadowMapResolver.cs


示例13: Absolute

        public void Absolute()
        {
            Vector4D v = new Vector4D(-1, -2, -3, -4);
              v.Absolute();

              Assert.AreEqual(1, v.X);
              Assert.AreEqual(2, v.Y);
              Assert.AreEqual(3, v.Z);
              Assert.AreEqual(4, v.W);

              v = new Vector4D(1, 2, 3, 4);
              v.Absolute();
              Assert.AreEqual(1, v.X);
              Assert.AreEqual(2, v.Y);
              Assert.AreEqual(3, v.Z);
              Assert.AreEqual(4, v.W);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:17,代码来源:Vector4DTest.cs


示例14: AbsoluteStatic

        public void AbsoluteStatic()
        {
            Vector4D v = new Vector4D(-1, -2, -3, -4);
              Vector4D absoluteV = Vector4D.Absolute(v);

              Assert.AreEqual(1, absoluteV.X);
              Assert.AreEqual(2, absoluteV.Y);
              Assert.AreEqual(3, absoluteV.Z);
              Assert.AreEqual(4, absoluteV.W);

              v = new Vector4D(1, 2, 3, 4);
              absoluteV = Vector4D.Absolute(v);
              Assert.AreEqual(1, absoluteV.X);
              Assert.AreEqual(2, absoluteV.Y);
              Assert.AreEqual(3, absoluteV.Z);
              Assert.AreEqual(4, absoluteV.W);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:17,代码来源:Vector4DTest.cs


示例15: Magnitude

        public void Magnitude()
        {
            Vector4D v = new Vector4D(3.0, 4.0, 0.0, 0.0);
            Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0, v.Magnitude, 1e-14);

            v = new Vector4D(3.0, 0.0, 4.0, 0.0);
            Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0, v.Magnitude, 1e-14);

            v = new Vector4D(0.0, 3.0, 4.0, 0.0);
            Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0, v.Magnitude, 1e-14);

            v = new Vector4D(0.0, 0.0, 3.0, 4.0);
            Assert.AreEqual(25.0, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0, v.Magnitude, 1e-14);
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:18,代码来源:Vector4DTests.cs


示例16: BulidSphere

        public static TriMesh BulidSphere(string data)//通过文件建立Trimesh
        {
            data = "D:\\atet.obj";
            TriMesh sphere= FromObjFile(data);
            Matrix4D m = new Matrix4D();
            m[0, 0] = 0.01; m[1, 1] = 0.01; m[2, 2] = 0.01;
            Vector4D v = new Vector4D();
            for (int i = 0; i < sphere.Vertices.Count; i++)//对整个球进行缩放
            {
                v.x = sphere.Vertices[i].Traits.Position.x;
                v.y = sphere.Vertices[i].Traits.Position.y;
                v.z = sphere.Vertices[i].Traits.Position.z;
                v.w = 1;
                v *= m;
                sphere.Vertices[i].Traits.Position.x = v.x;
                sphere.Vertices[i].Traits.Position.y = v.y;
                sphere.Vertices[i].Traits.Position.z = v.z;
             }

            return sphere;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:21,代码来源:TrimeshCreateSphere.cs


示例17: ProcessImage

        public override void ProcessImage(RenderImage image)
        {
            if (_noiseBase == null)
                GenerateNoise(32);

            var shadowColor = new Vector4D(1, 0, 0, 1);
            var midtoneColor = new Vector4D(0, 0, 1, 1);
            var highlightColor = new Vector4D(0, 1, 0, 1);
            Gorgon.CurrentRenderTarget = copyImage;
            Gorgon.CurrentShader = _shader;
            _shader.Parameters["xTime"].SetValue(_duration/20);
            _shader.Parameters["xOvercast"].SetValue(1.0f);
            _shader.Parameters["NoiseTexture"].SetValue(_noiseBase);
            _shader.Parameters["SceneTexture"].SetValue(image);
            //_shader.Parameters["shadowColor"].SetValue(shadowColor);
            //_shader.Parameters["midtoneColor"].SetValue(midtoneColor);
            //_shader.Parameters["highlightColor"].SetValue(highlightColor);

            _noiseBase.Blit(0, 0, image.Width, image.Height);
            Gorgon.CurrentShader = null;
            Gorgon.CurrentRenderTarget = null;

            image.CopyFromImage(copyImage.Image);
        }
开发者ID:Gartley,项目名称:ss13remake,代码行数:24,代码来源:PerlinPostProcessingEffect.cs


示例18: ToColor

 private Color ToColor(Vector4D color)
 {
     color = Limit(color);
     return Color.FromArgb((int) color.X, (int)color.Y, (int)color.Z, (int)color.W);
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:5,代码来源:ParticleSystem.cs


示例19: RefineFoundPath

        private void RefineFoundPath(ref Vector3D begin, ref Vector3D end, MyPath<MyNavigationPrimitive> path)
        {
            Debug.Assert(MyPerGameSettings.EnablePathfinding, "Pathfinding is not enabled!");
            if (!MyPerGameSettings.EnablePathfinding)
            {
                return;
            }

            if (path == null)
            {
                Debug.Assert(false, "Path to refine was null!");
                return;
            }

            m_currentPrimitive = path[path.Count - 1].Vertex as MyNavigationPrimitive;
            if (m_hlBegin != null && !m_pathNodes.Contains(m_hlBegin))
            {
                m_hlBegin.Parent.StopObservingPrimitive(m_hlBegin, this);
            }
            m_hlBegin = m_currentPrimitive.GetHighLevelPrimitive();
            if (m_hlBegin != null && !m_pathNodes.Contains(m_hlBegin))
            {
                m_hlBegin.Parent.ObservePrimitive(m_hlBegin, this);
            }

            ProfilerShort.Begin("Path refining and post-processing");
            IMyNavigationGroup prevGroup = null;
            int groupStart = 0;
            int groupEnd = 0;
            Vector3 prevBegin = default(Vector3);
            Vector3 prevEnd = default(Vector3);
            for (int i = 0; i < path.Count; ++i)
            {
                var primitive = path[i].Vertex as MyNavigationPrimitive;
                var group = primitive.Group;

                if (prevGroup == null)
                {
                    prevGroup = group;
                    prevBegin = prevGroup.GlobalToLocal(begin);
                }

                bool lastPrimitive = i == path.Count - 1;

                if (group != prevGroup)
                {
                    groupEnd = i - 1;
                    prevEnd = prevGroup.GlobalToLocal(primitive.WorldPosition);
                }
                else if (lastPrimitive)
                {
                    groupEnd = i;
                    prevEnd = prevGroup.GlobalToLocal(end);
                }
                else
                {
                    continue;
                }

                int refinedBegin = m_expandedPath.Count;
                prevGroup.RefinePath(path, m_expandedPath, ref prevBegin, ref prevEnd, groupStart, groupEnd);
                int refinedEnd = m_expandedPath.Count;
                for (int j = refinedBegin; j < refinedEnd; ++j)
                {
                    Vector3D position = new Vector3D(m_expandedPath[j]);
                    position = prevGroup.LocalToGlobal(position);

                    m_expandedPath[j] = new Vector4D(position, m_expandedPath[j].W);
                }

                if (lastPrimitive && group != prevGroup)
                {
                    m_expandedPath.Add(new Vector4D(primitive.WorldPosition, m_expandedPath[refinedEnd - 1].W));
                }

                prevGroup = group;
                groupStart = i;
                if (m_expandedPath.Count != 0)
                    prevBegin = group.GlobalToLocal(new Vector3D(m_expandedPath[m_expandedPath.Count - 1]));
            }

            m_pathNodePosition++;

            //m_expandedPath.RemoveAt(0);
            m_expandedPathPosition = 0;

            ProfilerShort.End();
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:88,代码来源:MySmartPath.cs


示例20: VariedPositiveVector4D

 private Vector4D VariedPositiveVector4D(Vector4D value, float variance)
 {
     return new Vector4D(
         VariedPositiveFloat(value.X, variance),
         VariedPositiveFloat(value.Y, variance),
         VariedPositiveFloat(value.Z, variance),
         VariedPositiveFloat(value.W, variance)
         );
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:9,代码来源:ParticleSystem.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Vector4F类代码示例发布时间:2022-05-24
下一篇:
C# Vector4类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap