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


C# Matrix3D.Translate方法代码示例

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


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

示例1: Main

    static void Main(string[] args)
    {
      navigationMatrix = new Matrix3D();
      navigationMatrix.Translate(new Vector3D(0, 100, 110));
      navigationMatrix.Scale(new Vector3D((double)1 / 5, (double)1 / 5, (double)1 / 5));

      displayProfile = new Bin[Bin.RANGEL, Bin.RANGEA, Bin.RANGEB];
      for (int l = 0; l < Bin.RANGEL; l++)
        for (int a = 0; a < Bin.RANGEA; a++)
          for (int b = 0; b < Bin.RANGEB; b++)
            displayProfile[l, a, b] = new Bin(l, a, b);

      PopulateProfile(displayProfile, navigationMatrix);

      String path = Environment.CurrentDirectory + PATH_TO_VIDEO;
      if (!System.IO.File.Exists(path))
        return;


      //Opens the movie file
      capture = new Capture(path);
      double fps = capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);

      //Reads frame by frame
      Timer timer = new Timer(1000 / fps);
      timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
      timer.Start();

      Console.Read();
    }
开发者ID:hcilab-um,项目名称:STColorCorrection,代码行数:30,代码来源:Program.cs

示例2: SetViewMatrix

        /// <summary>
        /// LookAtRH
        /// </summary>
        /// http://msdn.microsoft.com/en-us/library/bb281711(v=vs.85).aspx
        /// <returns></returns>
        public static Matrix3D SetViewMatrix(Point3D cameraPosition, Vector3D lookDirection, Vector3D upDirection)
        {
            // Normalize vectors:
            lookDirection.Normalize();
            upDirection.Normalize();
            double dotProduct = Vector3D.DotProduct(lookDirection, upDirection);
            // Define vectors, XScale, YScale, and ZScale:
            double denom = Math.Sqrt(1 - Math.Pow(dotProduct, 2));
            Vector3D XScale = Vector3D.CrossProduct(lookDirection, upDirection) / denom;
            Vector3D YScale = (upDirection - dotProduct * lookDirection) / denom;
            Vector3D ZScale = lookDirection;

            // Construct M matrix:
            Matrix3D M = new Matrix3D()
            {
                M11 = XScale.X, M12 = YScale.X, M13 = ZScale.X,
                M21 = XScale.Y, M22 = YScale.Y, M23 = ZScale.Y,
                M31 = XScale.Z, M32 = YScale.Z, M33 = ZScale.Z
            };

            // Translate the camera position to the origin:
            Matrix3D translateMatrix = new Matrix3D();
            translateMatrix.Translate(new Vector3D(-cameraPosition.X, -cameraPosition.Y, -cameraPosition.Z));
            // Define reflect matrix about the Z axis:
            Matrix3D reflectMatrix = new Matrix3D();
            reflectMatrix.M33 = -1;

            // Construct the View matrix:
            Matrix3D viewMatrix = translateMatrix * M * reflectMatrix;
            return viewMatrix;
        }
开发者ID:hcilab-um,项目名称:STim,代码行数:36,代码来源:Math3D.cs

示例3: SetupMatrices

 static void SetupMatrices()
 {
     mx1 = new Matrix3D();
     mx1.Translate(new Vector3D(0, -2.4, 0));
     mx2 = new Matrix3D();
     mx3 = new Matrix3D();
     mx3.Translate(new Vector3D(0, 2.4, 0));
     mx4 = new Matrix3D();
     mx4.Translate(new Vector3D(0, 0, -1));
 }
开发者ID:MartinDoms,项目名称:Fray,代码行数:10,代码来源:Program.cs

示例4: GetLocalToParent

 public static Matrix3D GetLocalToParent(IDictionary dictionary)
 {
     var matrix3D = new Matrix3D();
     if (dictionary != null)
     {
         var rotations = Helpers.IDictionaryHelper.GetRotationsXYZ(dictionary);
         matrix3D = Helpers.Matrix3DHelper.RotateXYZ(new Matrix3D(), Helpers.IDictionaryHelper.GetRotationsXYZ(dictionary));
         matrix3D.Translate(Helpers.IDictionaryHelper.GetTranslation(dictionary));
     }
     return matrix3D;
 }
开发者ID:node-net,项目名称:Node.Net,代码行数:11,代码来源:IDictionaryHelper.cs

示例5: GetTransform3D

        private static Transform3D GetTransform3D(IDictionary source, IFactory factory)
        {
            // transform should NOT include Scale
            ITranslation itranslation = null;
            IRotations irotations = null;
            if (factory != null)
            {
                itranslation = factory.Create<ITranslation>(source,null);
                irotations = factory.Create<IRotations>(source,null);
                var matrix3D = new Matrix3D();
                if (irotations != null) matrix3D = IMatrix3DHelper.RotateXYZ(new Matrix3D(), irotations.RotationsXYZ);
                if (itranslation != null) matrix3D.Translate(itranslation.Translation);

                if (!matrix3D.IsIdentity)
                {
                    return new MatrixTransform3D { Matrix = matrix3D };
                }
            }
            return null;
        }
开发者ID:node-net,项目名称:Node.Net,代码行数:20,代码来源:Model3DHelper.cs

示例6: FromIDictionary

        public static IMatrix3D FromIDictionary(IDictionary source, IFactory factory_in)
        {
            IFactory factory = factory_in;
            if (factory == null) factory = Node.Net.Factories.Deprecated.Factory.Default;
            var matrix3D = new Matrix3D();
            var irotations = factory.Create<IRotations>(source,null);
            if (irotations == null) irotations = Node.Net.Factories.Deprecated.Factory.Default.Create<IRotations>(source,null);
            var iscale = factory.Create<IScale>(source,null);
            //if (iscale == null) iscale = Node.Net.Factories.Factory.Default.Create<IScale>(source);
            var itranslation = factory.Create<ITranslation>(source,null);
            if (itranslation == null) itranslation = factory.Create<ITranslation>(source,null);
            if (irotations != null)
            {
                matrix3D = RotateXYZ(new Matrix3D(), irotations.RotationsXYZ);
            }
            if (iscale != null) matrix3D.Scale(iscale.Scale);
            if (itranslation != null) matrix3D.Translate(itranslation.Translation);

            if (!matrix3D.IsIdentity)
            {
                return new ConcreteMatrix3D { Matrix3D = matrix3D };
            }
            return new ConcreteMatrix3D();
        }
开发者ID:node-net,项目名称:Node.Net,代码行数:24,代码来源:IMatrix3DHelper.cs

示例7: calculateTranslationMatrix

        private Matrix3D calculateTranslationMatrix(double x, double y, double z)
        {
            Matrix3D matrix = new Matrix3D();
            matrix.Translate(new Vector3D(x, y, z));

            return matrix;
        }
开发者ID:KinectStudienarbeit,项目名称:KinectStudienarbeit,代码行数:7,代码来源:BlenderModel.cs

示例8: Append

 internal override void Append(ref Matrix3D matrix)
 {
     matrix.Translate(new Vector3D(_cachedOffsetXValue, _cachedOffsetYValue, _cachedOffsetZValue));
 }
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:TranslateTransform3D.cs

示例9: TestOriginFinder

        public void TestOriginFinder(int sampleSize)
        {
            double error = 0;
            double totalDur = 0;
            Random randomMaker = new Random(DateTime.Now.Millisecond);
            double maxErr = 0;

            for (int j = 0; j < sampleSize; j++)
            {
                Point3D[] standardPoints = new Point3D[]
                {
                    new Point3D(0, 0.5, 1.5), //top
                    new Point3D(0.5, 0.5, 1.5), //right
                    new Point3D(0, 0.5, 2), //front
                    new Point3D(-0.5, 0.25, 1.5) //back
                };

                Point3D[] capturePoints = new Point3D[standardPoints.Length];

                Matrix3D matrix = new Matrix3D();

                //matrix.Translate(new Vector3D(0, 10, 0));

                double size = 1;
                matrix.RotateAt(new Quaternion(new Vector3D((randomMaker.Next(1) - 1) * randomMaker.NextDouble() * size,
                                                                                                        (randomMaker.Next(1) - 1) * randomMaker.NextDouble() * size,
                                                                                                        randomMaker.NextDouble() * size),
                                                                                                        (randomMaker.Next(1) - 1) * randomMaker.NextDouble() * 360),
                                                                             new Point3D(0, 0, 0));

                matrix.Translate(new Vector3D((randomMaker.Next(1) - 1) * randomMaker.NextDouble() * size,
                                                                            (randomMaker.Next(1) - 1) * randomMaker.NextDouble() * size,
                                                                            (randomMaker.Next(1) - 1) * randomMaker.NextDouble() * size));

                for (int i = 0; i < standardPoints.Length; i++)
                {
                    capturePoints[i] = matrix.Transform(standardPoints[i]);
                }

                testOrigin = matrix.Transform(new Point3D());
                DateTime start = DateTime.Now.ToUniversalTime();
                Point3D newOrigin = this.BruteForceEstimateOrigin(standardPoints, capturePoints, 5);
                TimeSpan end = DateTime.Now.ToUniversalTime() - start;
                int duration = (int)end.TotalSeconds;
                totalDur += duration;
                Vector3D og = new Vector3D(testOrigin.X, testOrigin.Y, testOrigin.Z);
                Vector3D offset = new Vector3D(testOrigin.X - newOrigin.X, testOrigin.Y - newOrigin.Y, testOrigin.Z - newOrigin.Z);
                error += offset.Length;
                if (maxErr < offset.Length)
                {
                    maxErr = offset.Length;
                    Console.WriteLine("Max Error: {1}", j, Math.Round(maxErr, 6));
                }
            }
            double avgErr = error / sampleSize;
            double avgDur = totalDur / sampleSize;
            Console.WriteLine("Average Error: {0}\t Max Error: {1}", avgErr, maxErr);
        }
开发者ID:hcilab-um,项目名称:STim,代码行数:58,代码来源:OriginFinder.cs

示例10: translate

        /// <summary>
        /// Translate the point cloud by a given value
        /// </summary>
        /// <param name="tx">Up to three co-ords</param>
        public void translate(double[] tx)
        {
            if (tx.Length == 3) {
                //turn the transformation vector into and object
                Console.WriteLine("Translating");
                TranslateTransform3D translation = new TranslateTransform3D(tx[0], tx[1], tx[2]);

                //pull out the entire tree
                PARSE.ICP.PointRGB[] pts = this.getAllPoints();

                //create a new kd tree
                KdTree.KDTree newPoints = new KdTree.KDTree(3);

                //iterate over every point and translate + jam in new tree
                foreach(PARSE.ICP.PointRGB point in pts) {

                    //perform the new translation which does appear to work.
                    Matrix3D mtx = new Matrix3D();
                    mtx.Translate(new Vector3D(tx[0], tx[1], tx[2]));

                    //complete translation
                    Point3D newPoint = mtx.Transform(point.point);

                    //check if the x, y and z max and min coords need updating
                    //check min values
                    if (newPoint.X < minx) { minx = newPoint.X; }
                    if (newPoint.Y < miny) { miny = newPoint.Y; }
                    if (newPoint.Z < minz) { minz = newPoint.Z; }

                    //check max values
                    if (newPoint.X > maxx) { maxx = newPoint.X; }
                    if (newPoint.Y > maxy) { maxy = newPoint.Y; }
                    if (newPoint.Z > maxz) { maxz = newPoint.Z; }

                    //jam into the tree
                    double[] key = new double[3] { newPoint.X, newPoint.Y, newPoint.Z };
                    newPoints.insert(key, new PARSE.ICP.PointRGB(newPoint, point.r, point.g, point.b));

                    //perform the old translation method which doesn't appear to work.
                    //point.point.Offset(tx[0], tx[1], tx[2]);
                    //double[] key = new double[3]{point.point.X, point.point.Y, point.point.Z};
                    //newPoints.insert(key, point);
                }

                //replace the old kd tree with the new one
                this.points = newPoints;
            }
            else {
                //probably want to throw an exception here
            }
        }
开发者ID:robinj,项目名称:parse-client,代码行数:55,代码来源:PointCloud.cs

示例11: SetTransformMatrix

 private Matrix3D SetTransformMatrix(double offsetX, double offsetY, double offsetZ, int rotateAroundX)
 {
     Matrix3D resultMatrix = new Matrix3D();
     resultMatrix.Rotate(new Quaternion(new Vector3D(10, 0, 0), -rotateAroundX));
     resultMatrix.Translate(new Vector3D(offsetX, offsetY, -offsetZ));
     return resultMatrix;
 }
开发者ID:hcilab-um,项目名称:STim,代码行数:7,代码来源:Core.cs

示例12: ComposeMatrix

 private void ComposeMatrix()
 {
     if (_decomposeDirty)
     {
         _matrix = Matrix3D.Identity;
         _matrix.Translate(_translation);
         _matrix.Prepend(Math3D.CreateYawPitchRollMatrix(_rotation));
         _decomposeDirty = false;
     }
 }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:10,代码来源:Body.cs

示例13: UpdateOrCreateJoint

        public void UpdateOrCreateJoint(Joint joint)
        {
            int segments = 5;
            double jointRadius = 0.07;
            double boneRadius = 0.03;

            int jointId = (int)joint.ID;
            int connectedToJoint = SkeletonMetadata.BoneConnectionMapping[jointId];
            _jointPositions[jointId] = new Vector3D(joint.Position.X, joint.Position.Y, joint.Position.Z);

            // Create new 3d cube for the joint if not yet existing
            GeometryModel3D model;
            if (_joints[jointId] != null)
            {
                model = _joints[jointId];
            }
            else
            {
                model = Model3DFactory.CreateNormalizedSphere(defaultMaterial, segments);
                _environment.Children.Add(model);
                _joints[jointId] = model;

                if (connectedToJoint >= 0)
                {
                    GeometryModel3D cylinder = Model3DFactory.CreateNormalizedCylinder(defaultMaterial, segments);
                    _environment.Children.Add(cylinder);
                    _bones[jointId] = cylinder;
                }
            }

            // Performance improvement: not using a transformation group, but multiply
            // matrices first and use a single MatrixTransform3D
            var matrix = new Matrix3D();
            matrix.Scale(new Vector3D(jointRadius, jointRadius, jointRadius));
            matrix.Translate(new Vector3D(joint.Position.X, joint.Position.Y, joint.Position.Z));

            // Update position and the material/color (based on current tracking state), color right shoulder blue
            if (joint.ID == JointID.ShoulderRight)
                model.Material = rightShoulderIndicatorMaterial;
            else
                model.Material = _trackingStateMaterials[joint.TrackingState];
            model.Transform = new MatrixTransform3D(matrix);

            if (connectedToJoint >= 0)
            {
                GeometryModel3D bone = _bones[jointId];
                Vector3D boneStart = _jointPositions[jointId];
                Vector3D boneEnd = _jointPositions[connectedToJoint];
                Vector3D boneCenter = (boneStart + boneEnd) / 2;
                Vector3D boneVector = boneEnd - boneStart;

                // Again, compute a single transformation matrix and apply it to each bone
                var boneMatrix = new Matrix3D();
                boneMatrix.Scale(new Vector3D(boneRadius, boneRadius, boneVector.Length));
                boneMatrix.Rotate(GetQuaternionFromVectors(new Vector3D(0, 0, 1), boneVector));
                boneMatrix.Translate(boneCenter);

                bone.Material = _trackingStateMaterials[joint.TrackingState];
                bone.Transform = new MatrixTransform3D(boneMatrix); ;
            }
        }
开发者ID:philipdaubmeier,项目名称:BodyOrientation,代码行数:61,代码来源:Skeleton3d.cs

示例14: UpdateCameraMatrix

        private void UpdateCameraMatrix()
        {
            // right-handed coordinates

            #if false
            // front view
            var eye = new Vector3D(0.0, 0.0, -CameraDistance);
            var at = new Vector3D(0.0, 0.0, 0.0);
            var up = new Vector3D(0.0, 1.0, 0.0);
            var lookAt = WWMatrixUtil.CalculateLookAt(eye, at, up);
            #else
            // virtual trackball
            var cameraRot = mVirtualTrackball.RotationMatrix();
            var cameraTranslate = new Matrix3D();
            cameraTranslate.Translate(new Vector3D(0.0, 0.0, -mCameraDistanceCurrent));
            var cameraMat = cameraTranslate * cameraRot;
            var lookAt = cameraMat;
            lookAt.Invert();
            #endif

            var viewProjectionMatrix = WWMatrixUtil.CreatePerspectiveProjectionMatrix(mCameraNear, mCameraDistanceCurrent * 2.0, CameraFovHDegree, 1.0);

            mWorldProjectionMatrix = lookAt * viewProjectionMatrix;
        }
开发者ID:kekyo,项目名称:PlayPcmWin,代码行数:24,代码来源:WWRoomVisualizer.cs

示例15: RenderParticles

        /// <summary>
        /// パーティクルの描画設定をまとめて行います。
        /// </summary>
        public override void RenderParticles(IEnumerable<Particle> particles)
        {
            base.RenderParticles(particles);

            foreach (var particle in particles)
            {
                if (particle.Brush != null)
                {
                    var opacity = (double)((particle.Color >> 24) & 0xFF) / 255.0;

                    particle.Brush.Opacity = EffectObject.InheritedOpacity * opacity;
                }

                if (particle.Material != null)
                {
                    var em = particle.Material as EmissiveMaterial;
                    if (em != null)
                    {
                        em.Color = ToColor(particle.Color);
                    }
                    else
                    {
                        var dm = particle.Material as DiffuseMaterial;
                        if (dm != null)
                        {
                            dm.Color = ToColor(particle.Color);
                        }
                    }
                }

                // 行列変換
                var m = new Matrix3D();

                if (particle.Scale != 1.0)
                {
                    m.Scale(new Vector3D(particle.Scale, particle.Scale, 1.0));
                }

                if (particle.Rotation != 0.0)
                {
                    double rot = MathEx.ToDeg(particle.Rotation);
                    m.Rotate(new Quaternion(new Vector3D(0, 0, 1), rot));
                }

                m.Translate(new Vector3D(particle.X, particle.Y, -15.0));

                particle.Model.Transform = new MatrixTransform3D(m);
            }
        }
开发者ID:JuroGandalf,项目名称:Ragnarok,代码行数:52,代码来源:Model3DRenderer.cs


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