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


C# System.Matrix4d类代码示例

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


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

示例1: NextTranslationMatrix4d

 /// <summary>Create a random translation matrix.</summary>
 /// <param name="self"></param>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="result"></param>
 public static void NextTranslationMatrix4d(this Random self, double min, double max, out Matrix4d result)
 {
     Vector3d vmin, vmax;
     vmin.X = vmin.Y = vmin.Z = min;
     vmax.X = vmax.Y = vmax.Z = max;
     self.NextTranslationMatrix4d(ref vmin, ref vmax, out result);
 }
开发者ID:Burton-Radons,项目名称:Alexandria,代码行数:12,代码来源:Extensions.General.cs

示例2: Project

        private static bool Project(ref Vector3d world, ref Matrix4d modelviewMatrix, ref Matrix4d projectionMatrix, int[] viewport, out Vector3d screen)
        {
            Vector4d _in = new Vector4d(world, 1.0);
            Vector4d _out = new Vector4d();

            Vector4d.Transform(ref _in, ref modelviewMatrix, out _out);
            Vector4d.Transform(ref _out, ref projectionMatrix, out _in);

            if (_in.W == 0.0)
            {
                screen = Vector3d.Zero;
                return false;
            }

            _in.X /= _in.W;
            _in.Y /= _in.W;
            _in.Z /= _in.W;

            /* Map x, y and z to range 0-1 */
            _in.X = _in.X * 0.5 + 0.5;
            _in.Y = _in.Y * 0.5 + 0.5;
            _in.Z = _in.Z * 0.5 + 0.5;

            /* Map x,y to viewport */
            _in.X = _in.X * viewport[2] + viewport[0];
            _in.Y = _in.Y * viewport[3] + viewport[1];

            screen = new Vector3d(_in);
            return true;
        }
开发者ID:kskjer,项目名称:SceneNavi,代码行数:30,代码来源:ScreenWorldConversion.cs

示例3: Matrix4

 public Matrix4(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44)
     : this()
 {
     OpenTKEquivalent = new Matrix4d(m11, m12, m13, m14,
                                     m21, m22, m23, m24,
                                     m31, m32, m33, m34,
                                     m41, m42, m43, m44);
 }
开发者ID:Azzi777,项目名称:Lux,代码行数:8,代码来源:Matrix4.cs

示例4: WorldToScreen

        public static Vector3d WorldToScreen(Vector3d pos, Matrix4d modelviewMatrix, Matrix4d projectionMatrix, int[] viewport)
        {
            Vector3d point;
            Project(ref pos, ref modelviewMatrix, ref projectionMatrix, viewport, out point);
            point.Y = (float)viewport[3] - point.Y;

            return point;
        }
开发者ID:kskjer,项目名称:SceneNavi,代码行数:8,代码来源:ScreenWorldConversion.cs

示例5: GetOpenGLPNameInfo

 public List<KeyValuePair<string, string>> GetOpenGLPNameInfo()
 {
     List<KeyValuePair<string, string>> info = 
         new List<KeyValuePair<string, string>>(); 
     foreach (GetPName pname in Enum.GetValues(typeof(GetPName)))
     {
         double[] buff = new double[32];
         GL.GetDouble(pname, buff);
         int last = 0;
         for (int i = 0; i < 32; i++)
         {
             if (buff[i] != 0.0)
             {
                 last = i + 1;
             }
         }
         string str = null;
         switch (last)
         {
             case 0:
                 str = "0";
                 break;
             case 1:
                 str = buff[0].ToString();
                 break;
             case 2:
                 Vector2d v2 = new Vector2d(buff[0], buff[1]);
                 str = v2.ToString();
                 break;
             case 3:
                 Vector3d v3 = new Vector3d(buff[0], buff[1], buff[2]);
                 str = v3.ToString();
                 break;
             case 4:
                 Vector4d v4 = new Vector4d(buff[0], buff[1], buff[2], buff[3]);
                 str = v4.ToString();
                 break;
             case 16:
                 Matrix4d m4 = new Matrix4d(buff[0], buff[1], buff[2], buff[3],
                                         buff[4], buff[5], buff[6], buff[7],
                                         buff[8], buff[9], buff[10], buff[11],
                                         buff[12], buff[13], buff[14], buff[15]);
                 str = m4.ToString();
                 break;
             default:
                 StringBuilder sb = new StringBuilder();
                 for (int i = 0; i < last; i++)
                 {
                     sb.Append(buff[i]);
                     sb.Append(',');
                 }
                 str = sb.ToString();
                 break;
         }
         info.Add(new KeyValuePair<string, string>(pname.ToString(), str));
     } 
     return info;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:58,代码来源:OpenGLInfo.cs

示例6: Render

        public void Render(ICamera camera, ICamera lodCamera, Vector3d lightPosition)
        {
            var transformation = new Matrix4d(
                new Vector4d(1, 0, 0, 0),
                new Vector4d(0, 0, 1, 0),
                new Vector4d(0, 1, 0, 1),
                new Vector4d(0, 0, 0, 1));

            var visibleChunks = _chunkedLod.Calculate(
                _tree,
                lodCamera.Width,
                lodCamera.HorizontalFieldOfView,
                Vector3d.Transform(lodCamera.Position, transformation),
                30,
                FrustumPlaneExtractor.ExtractRowMajor(transformation * lodCamera.ComputeCameraMatrix() * lodCamera.ComputeProjectionMatrix()));

            GL.ClearColor(Color4.White);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.Enable(EnableCap.DepthTest);
            GL.CullFace(CullFaceMode.Back);
            GL.Enable(EnableCap.CullFace);
            GL.FrontFace(FrontFaceDirection.Cw);

            _simpleMaterial.Bind();

            _simpleMaterial.ProjectionMatrix.Set(camera.ComputeProjectionMatrix().ToMatrix4());
            _simpleMaterial.ViewMatrix.Set(camera.ComputeCameraMatrix().ToMatrix4());
            _simpleMaterial.LightDirection.Set(new Vector3(1, 1, 0).Normalized());

            _simpleMaterial.Color.Set(new Vector4(0.9f, 0.9f, 0.9f, 1.0f));

            foreach (var chunkedLodTreeNode in visibleChunks)
            {
                var renderableMesh = _cache.GetRenderable(chunkedLodTreeNode.Bounds);
                if (renderableMesh == null)
                    continue;

                renderableMesh.CreateVAO();
                renderableMesh.VertexArrayObject.Bind();

                var bounds = chunkedLodTreeNode.Bounds;
                var translation = Matrix4.CreateTranslation((float)bounds.Center.X, 0, (float)bounds.Center.Y);
                var delta = bounds.Max - bounds.Min;
                var scale = Matrix4.CreateScale((float)delta.X, 1, (float)delta.Y);

                var modelMatrix = scale * translation;
                _simpleMaterial.ModelMatrix.Set(modelMatrix);
                _simpleMaterial.NormalToWorld3x3.Set(new Matrix3(Matrix4.Transpose(modelMatrix.Inverted())));

                _simpleMaterial.LightPosition.Set((Vector3)lightPosition);

                GL.DrawElements(BeginMode.Triangles, renderableMesh.Faces * 3, DrawElementsType.UnsignedInt, 0);

                renderableMesh.VertexArrayObject.Unbind();
            }
            _simpleMaterial.Unbind();
        }
开发者ID:HaKDMoDz,项目名称:ProceduralGeneration,代码行数:58,代码来源:Terrain.cs

示例7: Transform

 public static Vector3[] Transform(Vector3[] vectors, Matrix4d matrix)
 {
     Vector3[] vList = new Vector3[vectors.Length];
     for (int i = 0; i < vectors.Length; i++)
     {
         vList[i] = (Vector3)Vector3d.Transform(new Vector3d(vectors[i].X, vectors[i].Y, vectors[i].Z), matrix);
     }
     return vList;
 }
开发者ID:AyyTee,项目名称:Aventyr,代码行数:9,代码来源:Vector3Ext.cs

示例8: ToGL

		public static Matrix4d ToGL(Matrix4x4 matrix)
		{
			Matrix4d value = new Matrix4d(
				matrix.m11, matrix.m12, matrix.m13, matrix.m14,
				matrix.m21, matrix.m22, matrix.m23, matrix.m24,
				matrix.m31, matrix.m32, matrix.m33, matrix.m34,
				matrix.m41, matrix.m42, matrix.m43, matrix.m44
				);
			return value;
		}
开发者ID:elliotwoods,项目名称:VVVV.Nodes.GL,代码行数:10,代码来源:UMath.cs

示例9: CommitRotation

        public void CommitRotation(Vector2d startPoint, Vector2d endPoint)
        {
            var rotation = CalculateRotation(startPoint, endPoint);
            var rotationMatrix = rotation.GetRotationMatrix();

            _cameraOrientation = _cameraOrientation.Multiply(rotationMatrix);
            _tempCameraOrientation = Matrix4d.Identity;

            FireCameraChanged();
        }
开发者ID:Valax321,项目名称:SPUD-Engine,代码行数:10,代码来源:TrackballCamera.cs

示例10: moveCamera

 public void moveCamera(Vector3d whatPosition)
 {
     Vector3d normalizedConnection = Vector3d.NormalizeFast(position - target);
     double cosine = Vector3d.Dot(normalizedConnection, Vector3d.UnitY);
     if (!(cosine < 1.02 && cosine > 0.98) && !(cosine > -1.02 && cosine < -0.98))
     {
         position = whatPosition;
         cameraMatrix = Matrix4d.LookAt(position, target, Vector3d.UnitY);
     }
 }
开发者ID:jobmayhc,项目名称:a-star-search-algorithm-in-csharp,代码行数:10,代码来源:Camera.cs

示例11: Project

 // https://gist.github.com/871099/8d37734ba22737c69173c2e44eaa332f9c85bcde
 // http://www.opentk.com/node/1892
 // http://www.opentk.com/node/1276
 // http://www.opentk.com/node/887
 // http://mesa3d.org/
 /// <summary>
 /// Projects a coordinate from world space into screen space.
 /// </summary>
 /// <param name="coordinate">The coordinate to project</param>
 /// <param name="viewport">The viewport dimensions</param>
 /// <param name="projection">The projection matrix</param>
 /// <param name="modelview">The modelview matrix</param>
 /// <returns>The coordinate in screen space.</returns>
 public static Coordinate Project(Coordinate coordinate, int[] viewport, Matrix4d projection, Matrix4d modelview)
 {
     var source = new Vector4d(coordinate.DX, coordinate.DY, coordinate.DZ, 1);
     var imed = Vector4d.Transform(source, modelview);
     var vector = Vector4d.Transform(imed, projection);
     if (Math.Abs(vector.W - 0) < 0.00001) return null;
     var result = Vector3d.Divide(vector.Xyz, vector.W);
     result.X = viewport[0] + viewport[2] * (result.X + 1) / 2;
     result.Y = viewport[1] + viewport[3] * (result.Y + 1) / 2;
     result.Z = (result.Z + 1) / 2;
     return new Coordinate((decimal) result.X, (decimal) result.Y, (decimal) result.Z);
 }
开发者ID:silky,项目名称:sledge,代码行数:25,代码来源:MathFunctions.cs

示例12: ImageLayer

 public ImageLayer()
 {
     objectToWorld = Matrix4d.Identity;
     WorldToObject = Matrix4d.Identity;
     Plane = new Plane()
     {
         Origin = new Vector3d(0, 0, -1),
         Normal = new Vector3d(0, 0, 1)
     };
     Depth = -20;
     FieldOfView = 0.5;
     RasterSize = new Size(1, 1);
 }
开发者ID:bzamecnik,项目名称:bokehlab,代码行数:13,代码来源:ImageLayer.cs

示例13: Unproject

 /// <summary>
 /// Converts a screen space point into a corresponding point in world space.
 /// </summary>
 /// <param name="coordinate">The coordinate to project</param>
 /// <param name="viewport">The viewport dimensions</param>
 /// <param name="projection">The projection matrix</param>
 /// <param name="modelview">The modelview matrix</param>
 /// <returns>The coordinate in world space.</returns>
 public static Coordinate Unproject(Coordinate coordinate, int[] viewport, Matrix4d projection, Matrix4d modelview)
 {
     var matrix = Matrix4d.Invert(Matrix4d.Mult(modelview, projection));
     var source = new Vector4d(
         (coordinate.DX - viewport[0]) * 2 / viewport[2] - 1,
         (coordinate.DY - viewport[1]) * 2 / viewport[3] - 1,
         2 * coordinate.DZ - 1,
         1);
     var vector = Vector4d.Transform(source, matrix);
     if (Math.Abs(vector.W - 0) < 0.00001) return null;
     var result = Vector3d.Divide(vector.Xyz, vector.W);
     return new Coordinate((decimal) result.X, (decimal) result.Y, (decimal) result.Z);
 }
开发者ID:silky,项目名称:sledge,代码行数:21,代码来源:MathFunctions.cs

示例14: AlmostEqual

 public static bool AlmostEqual(Matrix4d matrix0, Matrix4d matrix1, double delta, double percent)
 {
     for (int i = 0; i < MATRIX_4_SIZE; i++)
     {
         for (int j = 0; j < MATRIX_4_SIZE; j++)
         {
             if (Math.Abs(matrix0[i, j] - matrix1[i, j]) > delta && Math.Abs(1 - matrix1[i, j] / matrix0[i, j]) > percent)
             {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:AyyTee,项目名称:Aventyr,代码行数:14,代码来源:Matrix4Ext.cs

示例15: Multiply

        public static void Multiply(Matrix4d* mLeft, Matrix4d* mRight, Matrix4d* mOut)
        {
            double* s1 = mLeft->_data, s2 = mRight->_data;
            double* dPtr = mOut->_data;
            int index = 0;
            double val;

            for (int b = 0; b < 16; b += 4)
                for (int a = 0; a < 4; a++)
                {
                    val = 0.0;
                    for (int x = b, y = a; y < 16; y += 4)
                        val += s1[x++] * s2[y];
                    dPtr[index++] = val;
                }
        }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:16,代码来源:Matrix4d.cs


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