示例#1
0
        /// <summary>
        /// Compute the difference between two frames and return the result as a new frame from the point of view of the first.
        /// </summary>
        /// <param name="b1">The base frame.</param>
        /// <param name="b2">The frame to subtract from the base frame.</param>
        /// <param name="output">Returns the difference between the two frames in the form of a third frame.</param>
        public static void Subtract(ref Frame b1, ref Frame b2, out Frame output)
        {
            // apply inverse of b2's rotation to b1
            Matrix m1, m2, rel;

            b1.ToMatrix(out m1);
            b2.ToMatrix(out m2);
            Matrix.Transpose(ref m2, out m2);
            Matrix.Multiply(ref m1, ref m2, out rel);
            output.X = new Vector3(rel.M11, rel.M12, rel.M13);
            output.Y = new Vector3(rel.M21, rel.M22, rel.M23);
            output.Z = new Vector3(rel.M31, rel.M32, rel.M33);

            // subtract b2's position from b1
            Vector3.Subtract(ref b1.Origin, ref b2.Origin, out output.Origin);
        }
示例#2
0
		/// <summary>
		/// Compute the difference between two frames and return the result as a new frame from the point of view of the first.
		/// </summary>
		/// <param name="b1">The base frame.</param>
		/// <param name="b2">The frame to subtract from the base frame.</param>
		/// <param name="output">Returns the difference between the two frames in the form of a third frame.</param>
		public static void Subtract(ref Frame b1, ref Frame b2, out Frame output)
		{
			// apply inverse of b2's rotation to b1
			Matrix m1, m2, rel;
			b1.ToMatrix(out m1);
			b2.ToMatrix(out m2);
			Matrix.Transpose(ref m2, out m2);
			Matrix.Multiply(ref m1, ref m2, out rel);
			output.X = new Vector3(rel.M11, rel.M12, rel.M13);
			output.Y = new Vector3(rel.M21, rel.M22, rel.M23);
			output.Z = new Vector3(rel.M31, rel.M32, rel.M33);

			// subtract b2's position from b1
			Vector3.Subtract(ref b1.Origin, ref b2.Origin, out output.Origin);
		}