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

C# Matrix类代码示例

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

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



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

示例1: Pigeon

        public Pigeon(ContentManager con)
        {
            boundingBox = new Vector3(6, 3, 6);

            distance = 0;
            rand = new Random();

            dx = (0.5-rand.NextDouble())*0.8 + 0.2;
            dy = rand.NextDouble()*1.5 + 0.7;
            dz = 0.8;

            x = 5.8;
            y = -2;
            z = 83.5;

            sx = 5.8;
            sy = -2;
            sz = 83.5;

            this.world = Matrix.CreateTranslation(new Vector3((float)x, (float)y, (float)z));

            model = con.Load<Model>(@"models/pigeon");

            isDone = false;
        }
开发者ID:richardshelby,项目名称:TargetPractice,代码行数:25,代码来源:Pigeon.cs


示例2: Transform

 public void Transform(Matrix transform)
 {
     Vector2[] transformed = new Vector2[_vertices.Length];
     Vector2.Transform(_vertices.ToArray(), ref transform, transformed);
     _transformedvertices.Clear();
     _transformedvertices.vertices.InsertRange(0, transformed);
 }
开发者ID:fidgetwidget,项目名称:SmallGalaxy_Engine,代码行数:7,代码来源:Polygon.cs


示例3: Invert3x3

        public static Matrix Invert3x3(Matrix matrix)
        {
            Matrix destMat = Matrix.Identity;

            destMat.M11 = (matrix.M22 * matrix.M33 - matrix.M32 * matrix.M23);
            destMat.M21 = (matrix.M31 * matrix.M23 - matrix.M21 * matrix.M33);
            destMat.M31 = (matrix.M21 * matrix.M32 - matrix.M31 * matrix.M22);
            destMat.M12 = (matrix.M32 * matrix.M13 - matrix.M12 * matrix.M33);
            destMat.M22 = (matrix.M11 * matrix.M33 - matrix.M31 * matrix.M13);
            destMat.M32 = (matrix.M31 * matrix.M12 - matrix.M11 * matrix.M32);
            destMat.M13 = (matrix.M12 * matrix.M23 - matrix.M22 * matrix.M13);
            destMat.M23 = (matrix.M13 * matrix.M21 - matrix.M11 * matrix.M23);
            destMat.M33 = (matrix.M11 * matrix.M22 - matrix.M21 * matrix.M12);
            double invDet = 1.0 / (matrix.M11 * destMat.M11 + matrix.M21 * destMat.M12 + matrix.M31 * destMat.M13);

            destMat.M11 = (float)(destMat.M11 * invDet);
            destMat.M12 = (float)(destMat.M12 * invDet);
            destMat.M13 = (float)(destMat.M13 * invDet);
            destMat.M21 = (float)(destMat.M21 * invDet);
            destMat.M22 = (float)(destMat.M22 * invDet);
            destMat.M23 = (float)(destMat.M23 * invDet);
            destMat.M31 = (float)(destMat.M31 * invDet);
            destMat.M32 = (float)(destMat.M32 * invDet);
            destMat.M33 = (float)(destMat.M33 * invDet);

            return destMat;
        }
开发者ID:MattVitelli,项目名称:IslandAdventure,代码行数:27,代码来源:MathUtils.cs


示例4: Init

 public void Init(MyModel model, Matrix matrix, float rescaleModel = 1.0f)
 {
     Model = model;
     model.Rescale(rescaleModel);
     InstanceData.LocalMatrix = matrix;
     model.LoadData();
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyCubePart.cs


示例5: Execute

                /// <summary>
                /// Performs the <see cref="Closing"/> operator on the given
                /// <see cref="Matrix"/>.
                /// </summary>
                /// <param name="src">
                /// The <see cref="Matrix"/> which should be used by the
                /// operator.
                /// </param>
                /// <returns> The closed <see cref="Matrix"/>. </returns>
                public Matrix Execute (Matrix src)
                {
                        Dilation dilation = new Dilation (this.se);
                        Erosion erosion = new Erosion (this.se);

                        return (erosion.Execute (dilation.Execute (src)));
                }
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:16,代码来源:Closing.cs


示例6: GetDiagonalMatrix

 public static Matrix GetDiagonalMatrix()
 {
     Matrix ret = new Matrix();
     for (int i = 0; i < 4; i++)
         ret[i, i] = 1;
     return ret;
 }
开发者ID:Sharknevercries,项目名称:ParticleFilter,代码行数:7,代码来源:Matrix.cs


示例7: CalculateTransformedBoundingRectangle

        /// <summary>
        /// Calculates an axis aligned rectangle which fully contains an arbitrarily
        /// transformed axis aligned rectangle.
        /// </summary>
        /// <param name="rectangle">Original bounding rectangle.</param>
        /// <param name="transform">World transform of the rectangle.</param>
        /// <returns>A new rectangle which contains the trasnformed rectangle.</returns>
        public static Rectangle CalculateTransformedBoundingRectangle(Rectangle rectangle,
                                                           Matrix transform)
        {
            //   Matrix inverseMatrix = Matrix.Invert(transform);
            // Get all four corners in local space
            leftTop = new Vector2(rectangle.Left, rectangle.Top);
            rightTop = new Vector2(rectangle.Right, rectangle.Top);
            leftBottom = new Vector2(rectangle.Left, rectangle.Bottom);
            rightBottom = new Vector2(rectangle.Right, rectangle.Bottom);

            // Transform all four corners into work space
            Vector2.Transform(ref leftTop, ref transform, out leftTop);
            Vector2.Transform(ref rightTop, ref transform, out rightTop);
            Vector2.Transform(ref leftBottom, ref transform, out leftBottom);
            Vector2.Transform(ref rightBottom, ref transform, out rightBottom);

            // Find the minimum and maximum extents of the rectangle in world space
            min = Vector2.Min(Vector2.Min(leftTop, rightTop),
                                      Vector2.Min(leftBottom, rightBottom));
            max = Vector2.Max(Vector2.Max(leftTop, rightTop),
                                      Vector2.Max(leftBottom, rightBottom));

            // Return that as a rectangle
            return new Rectangle((int)Math.Round(min.X), (int)Math.Round(min.Y),
                                 (int)Math.Round(max.X - min.X), (int)Math.Round(max.Y - min.Y));
        }
开发者ID:Resinderate,项目名称:SensitiveWillum,代码行数:33,代码来源:Collision.cs


示例8: Draw

        public override void Draw(GameTime gameTime)
        {
            Matrix world = Matrix.CreateRotationY(this.rotation) * Matrix.CreateTranslation(this.position + (Vector3.Up * height));

            Matrix[] transforms = new Matrix[this.model.Bones.Count];
            this.model.CopyAbsoluteBoneTransformsTo(transforms);

            GraphicsDevice.BlendState = BlendState.AlphaBlend;
            GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = transforms[mesh.ParentBone.Index] * world;
                    effect.View = CanyonGame.Camera.View;
                    effect.Projection = CanyonGame.Camera.Projection;
                    effect.Alpha = this.alpha;
                    effect.EnableDefaultLighting();
                    effect.PreferPerPixelLighting = true;
                }

                mesh.Draw();
            }

            base.Draw(gameTime);
        }
开发者ID:koenbollen,项目名称:canyon,代码行数:28,代码来源:Marker.cs


示例9: Draw

        public override void Draw(Microsoft.Xna.Framework.Graphics.Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
        {

            if (firstTime)
            {
                oldViewProjection = world.CameraManager.ActiveCamera.ViewProjection;
                firstTime = false;
            }

            effect.Parameters["attenuation"].SetValue(Attenuation);
            effect.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
            effect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(world.CameraManager.ActiveCamera.ViewProjection));
            effect.Parameters["oldViewProjection"].SetValue(oldViewProjection);
            effect.Parameters["numSamples"].SetValue(NumSamples);
            effect.Parameters["depth"].SetValue(rHelper[PrincipalConstants.DephRT]);
            effect.Parameters["extra"].SetValue(rHelper[PrincipalConstants.extra1RT]);
            effect.Parameters["cena"].SetValue(ImageToProcess);

            oldViewProjection = world.CameraManager.ActiveCamera.ViewProjection;

            if (useFloatBuffer)
                rHelper.RenderFullScreenQuadVertexPixel(effect, SamplerState.PointClamp);
            else
                rHelper.RenderFullScreenQuadVertexPixel(effect, GraphicInfo.SamplerState);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:25,代码来源:MotionBlurPostEffect.cs


示例10: LinearlyIndependent

 public static bool LinearlyIndependent(params IVector[] vecs)
 {
     //reduce and see if there are zero rows
     Matrix temp = new Matrix(vecs);
     temp.GaussJordanEliminate();
     return !temp[temp.Height - 1].IsZero();
 }
开发者ID:SSheldon,项目名称:veccalc,代码行数:7,代码来源:VecOps.cs


示例11: InternalDraw

 protected override void InternalDraw(GameTime time, Matrix absoluteTransform, PrimitiveBatch primitiveBatch, Camera camera)
 {
     if (_mesh != null)
     {
         primitiveBatch.DrawMesh(_mesh, absoluteTransform, camera);
     }
 }
开发者ID:kekraft,项目名称:XNAProject,代码行数:7,代码来源:MeshNode.cs


示例12: DrawBuildings

        public override void DrawBuildings(GameTime gameTime)
        {
            base.DrawBuildings(gameTime);

            Model[] models = new Model[1];
            models[0] = GameResources.Inst().GetTreeModel(2);

            foreach (Model m in models)
            {
                Matrix[] transforms = new Matrix[m.Bones.Count];
                m.CopyAbsoluteBoneTransformsTo(transforms);

                foreach (ModelMesh mesh in m.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.Alpha = 1.0f;
                        effect.LightingEnabled = true;
                        effect.AmbientLightColor = GameState.MaterialAmbientColor;
                        effect.DirectionalLight0.Direction = GameState.LightDirection;
                        effect.DirectionalLight0.DiffuseColor = GameState.LightDiffusionColor;
                        effect.DirectionalLight0.SpecularColor = GameState.LightSpecularColor;
                        effect.DirectionalLight0.Enabled = true;
                        effect.World = transforms[mesh.ParentBone.Index] * worldM;
                        effect.View = GameState.view;
                        effect.Projection = GameState.projection;
                    }
                    mesh.Draw();
                }
            }
        }
开发者ID:alenkacz,项目名称:Expanze,代码行数:31,代码来源:DesertView.cs


示例13: Main

 public static void Main()
 {
     int n = 6;
     Matrix m = new Matrix(n);
     GameLogic.FillPath(m);
     m.PrintMatrix();
 }
开发者ID:zvet80,项目名称:TelerikAcademyHomework,代码行数:7,代码来源:MatrixMain.cs


示例14: RenderEmitter

        /// <summary>
        /// Renders the specified Emitter, applying the specified transformation offset.
        /// </summary>
        public override void RenderEmitter(Emitter emitter, ref Matrix transform)
        {
            Guard.ArgumentNull("emitter", emitter);
            Guard.IsTrue(this.Batch == null, "SpriteBatchRenderer is not ready! Did you forget to LoadContent?");

            if (emitter.ParticleTexture != null && emitter.ActiveParticlesCount > 0)
            {
                // Bail if the emitter blend mode is "None"...
                if (emitter.BlendMode == EmitterBlendMode.None)
                    return;

                // Calculate the source rectangle and origin offset of the Particle texture...
                Rectangle source = new Rectangle(0, 0, emitter.ParticleTexture.Width, emitter.ParticleTexture.Height);
                Vector2 origin = new Vector2(source.Width / 2f, source.Height / 2f);

                BlendState blendState = this.GetBlendState(emitter.BlendMode);

                this.Batch.Begin(SpriteSortMode.Deferred, blendState);

                for (int i = 0; i < emitter.ActiveParticlesCount; i++)
                {
                    Particle particle = emitter.Particles[i];

                    float scale = particle.Scale / emitter.ParticleTexture.Width;

                    this.Batch.Draw(emitter.ParticleTexture, particle.Position, source, new Color(particle.Colour), particle.Rotation, origin, scale, SpriteEffects.None, 0f);
                }

                this.Batch.End();
            }
        }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:34,代码来源:SpriteBatchRenderer.cs


示例15: Load

        /// <summary>
        /// Load matrix from XML file
        /// </summary>
        /// <param name="fileName">file name</param>
        /// <returns>Loaded matrix</returns>
        public Matrix Load(string fileName)
        {
            XmlTextReader textReader = new XmlTextReader(fileName);
            Matrix matrix = new Matrix();
            string fromWord = null;
            string toWord;
            float statisticValue;

            while (textReader.Read())
            {
                if (textReader.NodeType == XmlNodeType.Element)
                {
                    if (textReader.Name == "fromWord")
                    {
                        fromWord = textReader.GetAttribute("name");
                    }
                    else if (textReader.Name == "toWord")
                    {
                        if (fromWord != null)
                        {
                            toWord = textReader.GetAttribute("name");
                            float.TryParse(textReader.GetAttribute("statisticValue"), out statisticValue);
                            matrix.SetStatistics(fromWord, toWord, statisticValue);
                        }
                    }
                }
            }

            textReader.Close();

            return matrix;
        }
开发者ID:njg,项目名称:songlyricsstatis,代码行数:37,代码来源:XmlMatrixSaverLoader.cs


示例16: Update

 public void Update(Vector2 target)
 {
     position = target;
     matrix = Matrix.Identity;
     matrix *= Matrix.CreateTranslation(-position.X, -position.Y, 0);
     matrix *= Matrix.CreateTranslation(screenHalfW, screenHalfH, 0);
 }
开发者ID:KharonAlpua,项目名称:fantasy_farm,代码行数:7,代码来源:Camera.cs


示例17: UpdateBoundingBox

        public static BoundingBox UpdateBoundingBox(this Model model, Matrix worldTransform)
        {
            // Initialize minimum and maximum corners of the bounding box to max and min values
            Vector3 min = new Vector3 (float.MaxValue, float.MaxValue, float.MaxValue);
            Vector3 max = new Vector3 (float.MinValue, float.MinValue, float.MinValue);

            // For each mesh of the model
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    // Vertex buffer parameters
                    int vertexStride = meshPart.VertexBuffer.VertexDeclaration.VertexStride;
                    int vertexBufferSize = meshPart.NumVertices * vertexStride;

                    // Get vertex data as float
                    float[] vertexData = new float[vertexBufferSize / sizeof (float)];
                    meshPart.VertexBuffer.GetData<float> (vertexData);

                    // Iterate through vertices (possibly) growing bounding box, all calculations are done in world space
                    for (int i = 0; i < vertexBufferSize / sizeof (float); i += vertexStride / sizeof (float))
                    {
                        Vector3 transformedPosition = Vector3.Transform (new Vector3 (vertexData[i], vertexData[i + 1], vertexData[i + 2]), worldTransform);

                        min = Vector3.Min (min, transformedPosition);
                        max = Vector3.Max (max, transformedPosition);
                    }
                }
            }

            // Create and return bounding box
            return new BoundingBox (min, max);
        }
开发者ID:chillerman91,项目名称:GameAiChrisDaniel,代码行数:33,代码来源:ModelHelper.cs


示例18: Update

 /// <summary>
 /// Advances the current animation position.
 /// </summary>
 public void Update(TimeSpan time, bool relativeToCurrentTime,
                    Matrix rootTransform)
 {
     UpdateBoneTransforms(time, relativeToCurrentTime);
     UpdateWorldTransforms(rootTransform);
     UpdateSkinTransforms();
 }
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:10,代码来源:AnimationPlayer.cs


示例19: Main

        static void Main(string[] args)
        {
            Matrix matrix = new Matrix(8);
            matrix.Traverse();

            Console.WriteLine(matrix.ToString());
        }
开发者ID:androidejl,项目名称:Telerik,代码行数:7,代码来源:RotatingWalkExample.cs


示例20: Matrix

    public static Matrix operator *(Matrix matrixA, Matrix matrixB)
    {
        Matrix resultMatrix = new Matrix(matrixA.row, matrixB.col);
        if (matrixA.col != matrixB.row)
        {
            Console.WriteLine("You can't multiply this two matrices!");
            return resultMatrix;
        }
        else
        {

            for (int row = 0; row < resultMatrix.row; row++)
            {
                for (int col = 0; col < resultMatrix.col; col++)
                {
                    int value = 0;
                    for (int i = 0; i < matrixA.col; i++)
                    {
                        value = value + matrixA.matrix[row, i] * matrixB.matrix[i, col];
                    }
                    resultMatrix[row, col] = value;
                }
            }

            return resultMatrix;
        }
    }
开发者ID:YavorIT,项目名称:TelerikHomeworksBefore,代码行数:27,代码来源:Program.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Matrix3类代码示例发布时间:2022-05-24
下一篇:
C# Maticsoft类代码示例发布时间: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