예제 #1
0
 public static void Validate(this RigidTransform r)
 {
     r.Position.Validate();
     r.Orientation.Validate();
 }
        ///<summary>
        /// Concatenates a rigid transform with another rigid transform. Assumes input and output do not overlap.
        ///</summary>
        ///<param name="a">The first rigid transform.</param>
        ///<param name="b">The second rigid transform.</param>
        ///<param name="combined">Concatenated rigid transform.</param>
        public static void MultiplyWithoutOverlap(ref RigidTransform a, ref RigidTransform b, out RigidTransform combined)
        {
            Vector3 intermediate;

            Quaternion.Transform(a.Position, b.Orientation, out intermediate);
            combined.Position = intermediate + b.Position;
            Quaternion.ConcatenateWithoutOverlap(a.Orientation, b.Orientation, out combined.Orientation);
        }
 ///<summary>
 /// Concatenates a rigid transform with another rigid transform's inverse. Assumes input and output do not overlap.
 ///</summary>
 ///<param name="a">The first rigid transform.</param>
 ///<param name="b">The second rigid transform whose inverse will be concatenated to the first.</param>
 ///<param name="combinedTransform">Combined rigid transform.</param>
 public static void MultiplyByInverseWithoutOverlap(ref RigidTransform a, ref RigidTransform b, out RigidTransform combinedTransform)
 {
     Invert(ref b, out combinedTransform);
     MultiplyWithoutOverlap(ref a, ref combinedTransform, out combinedTransform);
 }
 /// <summary>
 /// Inverts a rigid transform.
 /// </summary>
 /// <param name="transform">Transform to invert.</param>
 /// <param name="inverse">Inverse of the transform.</param>
 public static void Invert(ref RigidTransform transform, out RigidTransform inverse)
 {
     Quaternion.Conjugate(transform.Orientation, out inverse.Orientation);
     Quaternion.Transform(transform.Position, inverse.Orientation, out inverse.Position);
     inverse.Position = -inverse.Position;
 }