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


C# Matrix3D.Invert方法代码示例

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


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

示例1: CalculateCubeTensor

        private void CalculateCubeTensor()
        {
            var factor = cubeMass * CubeSize * cubeSize;
            var d = 2.0 / 3.0 * factor;
            var nd = -1.0 / 4.0 * factor;

            cubeTensor = new Matrix3D(d, nd, nd, 0, nd, d, nd, 0, nd, nd, d, 0, 0, 0, 0, 1);
            invertCubeTensor = new Matrix3D(d, nd, nd, 0, nd, d, nd, 0, nd, nd, d, 0, 0, 0, 0, 1);
            invertCubeTensor.Invert();
        }
开发者ID:Arkady92,项目名称:VR,代码行数:10,代码来源:MainWindow.xaml.cs

示例2: OnRendering

        void OnRendering()
        {
            if (LineCollection.Count == 0)
            {
                return;
            }

            Matrix3D matx = VisualInfo.GetTotalTransform(this);

            if (matx == VisualInfo.ZeroMatrix)
            {
                return;
            }

            // How can this happen????
            if (matx.IsIdentity)
            {
                return;
            }

            if (matx != matxVisualToScreen)
            {
                matxVisualToScreen = matx;
                matxScreenToVisual = matx;

                if (matxScreenToVisual.HasInverse)
                {
                    matxScreenToVisual.Invert();                // might not be possible !!!!!!
                    needRecalculation = true;
                }
                else
                    throw new ApplicationException("Here's where the problem is");

            }

            if (needRecalculation)
            {
                Recalculate();
                needRecalculation = false;
            }
        }
开发者ID:samlcharreyron,项目名称:PedestrianTracker,代码行数:41,代码来源:WireBase.cs

示例3: PrependInverseTransform

		internal static void PrependInverseTransform( Matrix3D matrix, ref Matrix3D viewMatrix )
		{
			matrix.Invert();
			viewMatrix.Prepend( matrix );
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:5,代码来源:FactCubeCamera.cs

示例4: UpdateTransforms

        private bool UpdateTransforms()
        {
            Viewport3DVisual viewport;
            bool success;

            Matrix3D visualToScreen = MathUtils.TryTransformTo2DAncestor(this, out viewport, out success);

            if (!success || !visualToScreen.HasInverse)
                return false;

            if (visualToScreen == _visualToScreen)
                return false;

            _visualToScreen = _screenToVisual = visualToScreen;
            _screenToVisual.Invert();

            return true;
        }
开发者ID:dingxinbei,项目名称:OLdBck,代码行数:18,代码来源:ToolTip3D.cs

示例5: _updateMatricesAndShaderValues

      // updates the matrices and plane equation and sends it to the pixel shader.</summary>
      private void _updateMatricesAndShaderValues() {
         // Creating the worldViewProj matrix corresponding to the current plane transformation
         _worldViewProj = PlaneTransformation * _viewProjMatrix;
         if (RecenterViewport) {
            Point3D transformedCenter = _worldViewProj.Transform(new Point3D(0, 0, 0));
            ViewportOffset = new Point(transformedCenter.X, transformedCenter.Y);
            _hitTestingTransform.ViewportOffset = ViewportOffset;
         }
         _worldViewProjI = _worldViewProj;
         // and its inversed matrix
         _worldViewProjI.Invert();
         _hitTestingTransform.PlaneTransformation = _worldViewProj;
         _hitTestingTransform.InverseTransformation = _worldViewProjI;


         // Calculate the 3 coordinates of the plane after transformation
         var rawTopLeft = _worldViewProj.Transform(new Point3D(-1, 1, 0));
         var rawTopRight = _worldViewProj.Transform(new Point3D(1, 1, 0));
         var rawBottomLeft = _worldViewProj.Transform(new Point3D(-1, -1, 0));

         // compute the normal of the plane
         var planeNormal = Vector3D.CrossProduct((rawTopRight - rawTopLeft), (rawBottomLeft - rawTopLeft));
         planeNormal.Normalize();

         PlaneNormal = planeNormal;
         _hitTestingTransform.PlaneNormal = planeNormal;

         // and its distance from the origin
         this.PlaneDistance = -Vector3D.DotProduct(planeNormal, new Vector3D(rawTopLeft.X, rawTopLeft.Y, rawTopLeft.Z));
         _hitTestingTransform.PlaneDistance = this.PlaneDistance;

         // Pass it to the pixel shader
         M1 = new Point4D(_worldViewProjI.M11, _worldViewProjI.M12, _worldViewProjI.M13, _worldViewProjI.M14);
         M2 = new Point4D(_worldViewProjI.M21, _worldViewProjI.M22, _worldViewProjI.M23, _worldViewProjI.M24);
         M3 = new Point4D(_worldViewProjI.M31, _worldViewProjI.M32, _worldViewProjI.M33, _worldViewProjI.M34);
         M4 = new Point4D(_worldViewProjI.OffsetX, _worldViewProjI.OffsetY, _worldViewProjI.OffsetZ, _worldViewProjI.M44);
      }
开发者ID:borkaborka,项目名称:gmit,代码行数:38,代码来源:PlaneProjectionEffect.cs

示例6: QuaternionVectorMultiply

        private Vector3D QuaternionVectorMultiply(Quaternion q, Vector3D v)
        {
            var xx = q.X * q.X;
            var xy = q.X * q.Y;
            var xz = q.X * q.Z;
            var xw = q.X * q.W;

            var yy = q.Y * q.Y;
            var yz = q.Y * q.Z;
            var yw = q.Y * q.W;

            var zz = q.Z * q.Z;
            var zw = q.Z * q.W;

            var m00 = 1 - 2 * (yy + zz);
            var m01 = 2 * (xy - zw);
            var m02 = 2 * (xz + yw);

            var m10 = 2 * (xy + zw);
            var m11 = 1 - 2 * (xx + zz);
            var m12 = 2 * (yz - xw);

            var m20 = 2 * (xz - yw);
            var m21 = 2 * (yz + xw);
            var m22 = 1 - 2 * (xx + yy);

            var matrix = new Matrix3D(m00, m10, m20, 0, m01, m11, m21, 0, m02, m12, m22, 0, 0, 0, 0, 1);
            matrix.Invert();
            return MatrixVectorMultiply(matrix, v);
        }
开发者ID:Arkady92,项目名称:VR,代码行数:30,代码来源:MainWindow.xaml.cs

示例7: MapJointsToVectors

        private Dictionary<JointType, Vector3D> MapJointsToVectors(IReadOnlyDictionary<JointType, Joint> joints)
        {
            //Vectors are added in the same order as the bodytree depthfirst search
            Dictionary<JointType, Vector3D> jointVectors = new Dictionary<JointType, Vector3D>();
            jointVectors.Add(JointType.SpineMid, SubtractJoints(joints[JointType.SpineMid], joints[JointType.SpineBase]));
            jointVectors.Add(JointType.SpineShoulder, SubtractJoints(joints[JointType.SpineShoulder], joints[JointType.SpineMid]));
            jointVectors.Add(JointType.ShoulderLeft, SubtractJoints(joints[JointType.ShoulderLeft], joints[JointType.SpineShoulder]));
            jointVectors.Add(JointType.ElbowLeft, SubtractJoints(joints[JointType.ElbowLeft], joints[JointType.ShoulderLeft]));
            jointVectors.Add(JointType.WristLeft, SubtractJoints(joints[JointType.WristLeft], joints[JointType.ElbowLeft]));
            jointVectors.Add(JointType.HandLeft, SubtractJoints(joints[JointType.HandLeft], joints[JointType.WristLeft]));
            jointVectors.Add(JointType.HandTipLeft, SubtractJoints(joints[JointType.HandTipLeft], joints[JointType.HandLeft]));
            jointVectors.Add(JointType.ThumbLeft, SubtractJoints(joints[JointType.ThumbLeft], joints[JointType.HandLeft]));
            jointVectors.Add(JointType.Neck, SubtractJoints(joints[JointType.Neck], joints[JointType.SpineShoulder]));
            jointVectors.Add(JointType.Head, SubtractJoints(joints[JointType.Head], joints[JointType.Neck]));
            jointVectors.Add(JointType.ShoulderRight, SubtractJoints(joints[JointType.ShoulderRight], joints[JointType.SpineShoulder]));
            jointVectors.Add(JointType.ElbowRight, SubtractJoints(joints[JointType.ElbowRight], joints[JointType.ShoulderRight]));
            jointVectors.Add(JointType.WristRight, SubtractJoints(joints[JointType.WristRight], joints[JointType.ElbowRight]));
            jointVectors.Add(JointType.HandRight, SubtractJoints(joints[JointType.HandRight], joints[JointType.WristRight]));
            jointVectors.Add(JointType.HandTipRight, SubtractJoints(joints[JointType.HandTipRight], joints[JointType.HandRight]));
            jointVectors.Add(JointType.ThumbRight, SubtractJoints(joints[JointType.ThumbRight], joints[JointType.HandRight]));
            jointVectors.Add(JointType.SpineBase, SubtractJoints(joints[JointType.SpineBase], new Joint()));
            jointVectors.Add(JointType.HipLeft, SubtractJoints(joints[JointType.HipLeft], joints[JointType.SpineBase]));
            jointVectors.Add(JointType.KneeLeft, SubtractJoints(joints[JointType.KneeLeft], joints[JointType.HipLeft]));
            jointVectors.Add(JointType.AnkleLeft, SubtractJoints(joints[JointType.AnkleLeft], joints[JointType.KneeLeft]));
            jointVectors.Add(JointType.FootLeft, SubtractJoints(joints[JointType.FootLeft], joints[JointType.AnkleLeft]));
            jointVectors.Add(JointType.HipRight, SubtractJoints(joints[JointType.HipRight], joints[JointType.SpineBase]));
            jointVectors.Add(JointType.KneeRight, SubtractJoints(joints[JointType.KneeRight], joints[JointType.HipRight]));
            jointVectors.Add(JointType.AnkleRight, SubtractJoints(joints[JointType.AnkleRight], joints[JointType.KneeRight]));
            jointVectors.Add(JointType.FootRight, SubtractJoints(joints[JointType.FootRight], joints[JointType.AnkleRight]));

            Matrix3D rotationMatrix = new Matrix3D();

            {
                Vector3D j = new Vector3D(0.0, 1.0, 0.0);

                Vector3D i = SubtractJoints(joints[JointType.HipRight], joints[JointType.HipLeft]);
                i.Normalize();

                Vector3D k = Vector3D.CrossProduct(i, j);
                k.Normalize();

                rotationMatrix.M11 = i.X;
                rotationMatrix.M12 = i.Y;
                rotationMatrix.M13 = i.Z;
                rotationMatrix.M21 = j.X;
                rotationMatrix.M22 = j.Y;
                rotationMatrix.M23 = j.Z;
                rotationMatrix.M31 = k.X;
                rotationMatrix.M32 = k.Y;
                rotationMatrix.M33 = k.Z;
            }

            rotationMatrix.Invert();

            for (int i = 0; i < jointVectors.Count; i++)
            {
                jointVectors[(JointType)i] = jointVectors[(JointType)i] * rotationMatrix;
                Vector3D normalized = jointVectors[(JointType)i];
                normalized.Normalize();
                jointVectors[(JointType)i] = normalized;
            }

            return jointVectors;
        }
开发者ID:caomw,项目名称:prepose,代码行数:64,代码来源:MainWindow.xaml.cs

示例8: WorkShop_MouseMove

        void WorkShop_MouseMove(object sender, MouseEventArgs e)
        {
            if (ActionType == ActionType.Rotate)
            {
                var currentMousePoint = e.GetPosition(this);
                var currentMouseVector = ProjectToTrackBall(currentMousePoint);

                Vector3D axis = Vector3D.CrossProduct(PreviousMouseVector, currentMouseVector);
                double angle = Vector3D.AngleBetween(PreviousMouseVector, currentMouseVector);

                if (axis.LengthSquared > 0)
                {
                    var rotation = RotateTransform.Rotation as QuaternionRotation3D;

                    if (rotation != null)
                    {
                        rotation.Quaternion = new Quaternion(axis, angle) * rotation.Quaternion;
                        PreviousMouseVector = currentMouseVector;
                    }
                }
            }
            else if (ActionType == ActionType.Translate)
            {
                var currentMousePoint = e.GetPosition(this);

                double multiplier = 2 * (Math.Tan(Math.PI / 8) / ScaleTransform.ScaleX) * 4;

                double deltaX = ((currentMousePoint.X - PreviousMousePoint.X) / Space.ActualWidth) * multiplier;
                double deltaY = -((currentMousePoint.Y - PreviousMousePoint.Y) / Space.ActualHeight) * multiplier;

                var deltaVector = new Vector3D(deltaX, deltaY, 0);
                var rotation = (QuaternionRotation3D)RotateTransform.Rotation;

                var matrix = new Matrix3D();
                matrix.Rotate(rotation.Quaternion);
                matrix.Invert();
                deltaVector = matrix.Transform(deltaVector);

                TranslateTransform.OffsetX += deltaVector.X;
                TranslateTransform.OffsetY += deltaVector.Y;
                TranslateTransform.OffsetZ += deltaVector.Z;

                PreviousMousePoint = currentMousePoint;
            }
        }
开发者ID:babaq,项目名称:Soul,代码行数:45,代码来源:WorkShop.xaml.cs

示例9: CaptureMouseMove

        private void CaptureMouseMove(object sender, MouseEventArgs e)
        {
            Point currentMousePoint = e.GetPosition(this);

            if (this.pdbViewer.ActionType == PdbActionType.Rotate)
            {
                Vector3D currentMouseVector3D = this.ProjectToTrackball(currentMousePoint);

                Vector3D axis = Vector3D.CrossProduct(
                    this.previousMouseVector, currentMouseVector3D);
                double angle = 2 * Vector3D.AngleBetween(
                    this.previousMouseVector, currentMouseVector3D);

                if (axis.LengthSquared > 0)
                {
                    QuaternionRotation3D rotation =
                        this.rotateTransform.Rotation as QuaternionRotation3D;

                    if (rotation != null)
                    {
                        rotation.Quaternion = new Quaternion(axis, angle) *
                            rotation.Quaternion;
                    }
                }

                this.previousMouseVector = currentMouseVector3D;
            }
            else if (this.pdbViewer.ActionType == PdbActionType.Select ||
                this.pdbViewer.ActionType == PdbActionType.Deselect &&
                currentMousePoint != this.previousMousePoint)
            {
                double left = Math.Min(this.previousMousePoint.X, currentMousePoint.X);
                double top = Math.Min(this.previousMousePoint.Y, currentMousePoint.Y);
                double right = this.ActualWidth -
                    Math.Max(this.previousMousePoint.X, currentMousePoint.X);
                double bottom = this.ActualHeight -
                    Math.Max(this.previousMousePoint.Y, currentMousePoint.Y);

                left = Math.Max(0, left);
                top = Math.Max(this.CaptureElement.TranslatePoint(new Point(), this).Y, top);
                right = Math.Max(0, right);
                bottom = Math.Max(0, bottom);

                this.selectionRectangle.Margin = new Thickness(left, top, right, bottom);
                this.selectionRectangle.Visibility = Visibility.Visible;

                Rect selectionRect = new Rect(this.previousMousePoint, currentMousePoint);

                foreach (Atom atom in this.Molecule.Atoms)
                {
                    Point? atomPoint = this.GetViewportCoordinatePoint3Ds(atom);

                    bool contained = atomPoint != null && selectionRect.Contains(atomPoint.Value);

                    if (contained)
                    {
                        if (this.pdbViewer.ActionType == PdbActionType.Select)
                            atom.ShowAsSelected = true;
                        else if (this.pdbViewer.ActionType == PdbActionType.Deselect)
                            atom.ShowAsSelected = false;
                    }
                    else
                    {
                        atom.ShowAsSelected = atom.IsSelected;
                    }
                }
            }
            else if (this.pdbViewer.ActionType == PdbActionType.Translate)
            {
                double multiplier = 2 * Math.Tan(Math.PI / 8) * cameraOffset /
                    this.scaleTransform.ScaleX;

                double deltaX = (currentMousePoint.X - this.previousMousePoint.X) /
                    this.viewport.ActualWidth * multiplier;
                double deltaY = -(currentMousePoint.Y - this.previousMousePoint.Y) /
                    this.viewport.ActualHeight * multiplier;

                Vector3D deltaVector = new Vector3D(deltaX, deltaY, 0);

                QuaternionRotation3D rotation =
                    (QuaternionRotation3D)this.rotateTransform.Rotation;

                Matrix3D matrix = new Matrix3D();
                matrix.Rotate(rotation.Quaternion);
                matrix.Invert();

                deltaVector = matrix.Transform(deltaVector);

                this.translateTransform.OffsetX += deltaVector.X;
                this.translateTransform.OffsetY += deltaVector.Y;
                this.translateTransform.OffsetZ += deltaVector.Z;

                this.previousMousePoint = currentMousePoint;
            }
        }
开发者ID:alkampfergit,项目名称:BaktunShell,代码行数:95,代码来源:StructureControl.cs

示例10: CreateZ3Body

        /// <summary>
        /// This function converts Kinect joints to a Z3 body.
        /// It also changes the basis of body coordinates to make it
        /// invariant to body position in relation to the sensor.
        /// 
        /// The origin of the new coordinate system is user hips.
        /// </summary>
        /// <param name="kinectJoints"></param>
        /// <returns></returns>
        public static Z3Body CreateZ3Body(
            IReadOnlyDictionary<Microsoft.Kinect.JointType, Microsoft.Kinect.Joint> 
            kinectJoints)
        {
            var jointVectors = new Dictionary<Microsoft.Kinect.JointType, Vector3D>();
            jointVectors.Add(Microsoft.Kinect.JointType.SpineMid, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.SpineMid], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointVectors.Add(Microsoft.Kinect.JointType.SpineShoulder, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.SpineShoulder], kinectJoints[Microsoft.Kinect.JointType.SpineMid]));
            jointVectors.Add(Microsoft.Kinect.JointType.ShoulderLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ShoulderLeft], kinectJoints[Microsoft.Kinect.JointType.SpineShoulder]));
            jointVectors.Add(Microsoft.Kinect.JointType.ElbowLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ElbowLeft], kinectJoints[Microsoft.Kinect.JointType.ShoulderLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.WristLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.WristLeft], kinectJoints[Microsoft.Kinect.JointType.ElbowLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.HandLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandLeft], kinectJoints[Microsoft.Kinect.JointType.WristLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.HandTipLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandTipLeft], kinectJoints[Microsoft.Kinect.JointType.HandLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.ThumbLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ThumbLeft], kinectJoints[Microsoft.Kinect.JointType.HandLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.Neck, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.Neck], kinectJoints[Microsoft.Kinect.JointType.SpineShoulder]));
            jointVectors.Add(Microsoft.Kinect.JointType.Head, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.Head], kinectJoints[Microsoft.Kinect.JointType.Neck]));
            jointVectors.Add(Microsoft.Kinect.JointType.ShoulderRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ShoulderRight], kinectJoints[Microsoft.Kinect.JointType.SpineShoulder]));
            jointVectors.Add(Microsoft.Kinect.JointType.ElbowRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ElbowRight], kinectJoints[Microsoft.Kinect.JointType.ShoulderRight]));
            jointVectors.Add(Microsoft.Kinect.JointType.WristRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.WristRight], kinectJoints[Microsoft.Kinect.JointType.ElbowRight]));
            jointVectors.Add(Microsoft.Kinect.JointType.HandRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandRight], kinectJoints[Microsoft.Kinect.JointType.WristRight]));
            jointVectors.Add(Microsoft.Kinect.JointType.HandTipRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandTipRight], kinectJoints[Microsoft.Kinect.JointType.HandRight]));
            jointVectors.Add(Microsoft.Kinect.JointType.ThumbRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ThumbRight], kinectJoints[Microsoft.Kinect.JointType.HandRight]));

            // Spine base is the root of the system, as it has no direction to store, it stores its own position
            jointVectors.Add(Microsoft.Kinect.JointType.SpineBase, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.SpineBase], new Joint()));
            jointVectors.Add(Microsoft.Kinect.JointType.HipLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HipLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointVectors.Add(Microsoft.Kinect.JointType.KneeLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.KneeLeft], kinectJoints[Microsoft.Kinect.JointType.HipLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.AnkleLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.AnkleLeft], kinectJoints[Microsoft.Kinect.JointType.KneeLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.FootLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.FootLeft], kinectJoints[Microsoft.Kinect.JointType.AnkleLeft]));
            jointVectors.Add(Microsoft.Kinect.JointType.HipRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HipRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointVectors.Add(Microsoft.Kinect.JointType.KneeRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.KneeRight], kinectJoints[Microsoft.Kinect.JointType.HipRight]));
            jointVectors.Add(Microsoft.Kinect.JointType.AnkleRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.AnkleRight], kinectJoints[Microsoft.Kinect.JointType.KneeRight]));
            jointVectors.Add(Microsoft.Kinect.JointType.FootRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.FootRight], kinectJoints[Microsoft.Kinect.JointType.AnkleRight]));

            var rotationMatrix = new Matrix3D();

            InitMatrix(out rotationMatrix, kinectJoints);

            rotationMatrix.Invert();

            var joints = new Dictionary<PreposeGestures.JointType, Z3Point3D>();
            var norms = new Dictionary<PreposeGestures.JointType, ArithExpr>();

            norms.Add(PreposeGestures.JointType.SpineBase, Z3Math.Real(jointVectors[Microsoft.Kinect.JointType.SpineBase].Length));
            joints.Add(PreposeGestures.JointType.SpineBase,
                       new Z3Point3D(
                        jointVectors[Microsoft.Kinect.JointType.SpineBase].X,
                        jointVectors[Microsoft.Kinect.JointType.SpineBase].Y,
                        jointVectors[Microsoft.Kinect.JointType.SpineBase].Z));

            var jointTypes = EnumUtil.GetValues<Microsoft.Kinect.JointType>();
            foreach (var jointType in jointTypes)
            {
                if (jointType != Microsoft.Kinect.JointType.SpineBase)
                {
                    jointVectors[jointType] = jointVectors[jointType] * rotationMatrix;

                    var z3Joint = Convert(jointType);

                    norms.Add(z3Joint, Z3Math.Real(jointVectors[jointType].Length));

                    var temp = jointVectors[jointType];
                    temp.Normalize();

                    joints.Add(
                        z3Joint,
                        new Z3Point3D(
                        temp.X,
                        temp.Y,
                        -temp.Z));
                }
            }

            return new Z3Body(joints, norms);
        }
开发者ID:caomw,项目名称:prepose,代码行数:83,代码来源:Z3KinectConverter.cs

示例11: GetFlatPoints

		/// <summary>
		/// Get flat (square) points facing camera
		/// </summary>
		/// <param name="cameraPos">Camera position</param>
		/// <param name="displayMatrix">View + projection + display matrix</param>
		/// <returns>Points</returns>
		protected Point3D[] GetFlatPoints( Point3D cameraPos, Matrix3D displayMatrix )
		{
			Vector3D perpendicular = Vector3D.CrossProduct( (Vector3D)position, (Vector3D)cameraPos );
			perpendicular.Normalize();

			Vector3D distance = bounds.Positions[ 0 ] - position;
			double radius = Math.Max( Math.Max( Math.Abs( distance.X ), Math.Abs( distance.Y ) ), Math.Abs( distance.Z ) );

			Point3D[] points = new Point3D[] { position, position + ( perpendicular * radius ) };
			displayMatrix.Transform( points );

			Point3D center = points[ 0 ];
			double half = ( points[ 1 ] - points[ 0 ] ).Length;

			points = new Point3D[] {
					new Point3D( center.X - half, center.Y - half, center.Z ),
					new Point3D( center.X + half, center.Y - half, center.Z ),
					new Point3D( center.X + half, center.Y + half, center.Z ),
					new Point3D( center.X - half, center.Y + half, center.Z ) };

			displayMatrix.Invert();
			displayMatrix.Transform( points );

			return points;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:31,代码来源:BSPCube.cs

示例12: ReadFromXMLNode

        public virtual void ReadFromXMLNode(XmlNode node)
        {
            // Read the origin node
            XmlNode originNode = node.SelectSingleNode(ModelXMLDefinition.pipeUCSOrigin);
            CPoint3D origin = CPoint3DSerializer.ReadPoint(originNode);

            // Read the x axis
            XmlNode xAxisNode = node.SelectSingleNode(ModelXMLDefinition.pipeUCSXAxis);
            CPoint3D xAxis = CPoint3DSerializer.ReadPoint(xAxisNode);

            // Read the x axis
            XmlNode yAxisNode = node.SelectSingleNode(ModelXMLDefinition.pipeUCSYAxis);
            CPoint3D yAxis = CPoint3DSerializer.ReadPoint(yAxisNode); ;

            // Calculate the UCS
            Vector3D vecX = new Vector3D(xAxis.X, xAxis.Y, xAxis.Z);
            vecX.Normalize();

            Vector3D vecY = new Vector3D(yAxis.X, yAxis.Y, yAxis.Z);
            vecY.Normalize();

            // Get the z axis
            Vector3D vecZ = Vector3D.CrossProduct(vecX, vecY);

            // Recalculate the y axis since yaxis may not be preh to xaxis.
            vecY = Vector3D.CrossProduct(vecZ, vecX);

            // Create matrix3d representation
            m_matrix3d = new Matrix3D(vecX.X, vecX.Y, vecX.Z, 0,
                                      vecY.X, vecY.Y, vecY.Z, 0,
                                      vecZ.X, vecZ.Y, vecZ.Z, 0,
                                      origin.X, origin.Y, origin.Z, 1.0);

            m_matrix3dInvert = new Matrix3D(vecX.X, vecX.Y, vecX.Z, 0,
                                            vecY.X, vecY.Y, vecY.Z, 0,
                                            vecZ.X, vecZ.Y, vecZ.Z, 0,
                                            origin.X, origin.Y, origin.Z, 1.0);
            m_matrix3dInvert.Invert();

            // Set transform
            m_tranform = m_matrix3d.ToVTKTransformation();
            m_tranformInvert.DeepCopy(m_tranform);
            m_tranformInvert.Inverse();
        }
开发者ID:unidevop,项目名称:sjtu-project-pipe,代码行数:44,代码来源:ucs.cs

示例13: KinectToHipsSpineCoordinateSystem

        /// <summary>
        /// This function converts Kinect joints to different coordinate system
        /// invariant to body position in relation to the sensor.
        /// The origin of the new coordinate system is middel point between the user hips.
        /// 
        /// </summary>
        /// <param name="kinectJoints"></param>
        /// <returns></returns>
        public static Dictionary<Microsoft.Kinect.JointType, Vector3D> KinectToHipsSpineCoordinateSystem(
            IReadOnlyDictionary<Microsoft.Kinect.JointType, Microsoft.Kinect.Joint>
            kinectJoints)
        {
            // positions are updated considering the spine base as center and a new coordinate system
            // with hips (left to right) as the X axis
            // (0,1,0) based on the senor as the Y axis
            // and the cross product between X and Y as the Z axis pointing towards the user front
            var jointPositionsRotated = new Dictionary<Microsoft.Kinect.JointType, Vector3D>();
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.SpineMid, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.SpineMid], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.SpineShoulder, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.SpineShoulder], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.ShoulderLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ShoulderLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.ElbowLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ElbowLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.WristLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.WristLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.HandLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.HandTipLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandTipLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.ThumbLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ThumbLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.Neck, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.Neck], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.Head, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.Head], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.ShoulderRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ShoulderRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.ElbowRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ElbowRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.WristRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.WristRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.HandRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.HandTipRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HandTipRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.ThumbRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.ThumbRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));

            // Spine base is the root of the system, as it has no direction to store, it stores its own position
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.SpineBase, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.SpineBase], new Joint()));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.HipLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HipLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.KneeLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.KneeLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.AnkleLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.AnkleLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.FootLeft, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.FootLeft], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.HipRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.HipRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.KneeRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.KneeRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.AnkleRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.AnkleRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));
            jointPositionsRotated.Add(Microsoft.Kinect.JointType.FootRight, SubtractJoints(kinectJoints[Microsoft.Kinect.JointType.FootRight], kinectJoints[Microsoft.Kinect.JointType.SpineBase]));

            var rotationMatrix = new Matrix3D();
            InitMatrix(out rotationMatrix, kinectJoints);
            rotationMatrix.Invert();

            var jointTypes = EnumUtil.GetValues<Microsoft.Kinect.JointType>();
            foreach (var jointType in jointTypes)
            {
                if (jointType != Microsoft.Kinect.JointType.SpineBase)
                {
                    var current = jointPositionsRotated[jointType];
                    var rotated = current * rotationMatrix;
                    jointPositionsRotated[jointType] = rotated;
                }
            }

            return jointPositionsRotated;
        }
开发者ID:lsfcin,项目名称:prepose,代码行数:62,代码来源:Z3KinectConverter.cs


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