Exemplo n.º 1
0
		/// <summary>
		/// Apply a transform to a frame to produce a new frame.
		/// </summary>
		/// <param name="input">The frame to transform.</param>
		/// <param name="transform">The transform to apply.</param>
		/// <param name="output">Returns the new, transformed frame.</param>
		public static void Transform(ref Frame input, ref Transform transform, out Frame output)
		{
			Vector3.Transform(ref input.X, ref transform.Orientation, out output.X);
			Vector3.Transform(ref input.Y, ref transform.Orientation, out output.Y);
			Vector3.Transform(ref input.Z, ref transform.Orientation, out output.Z);
			Vector3.Transform(ref input.Origin, ref transform.Combined, out output.Origin);
		}
Exemplo n.º 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);
		}