using System; using System.Collections.Generic; namespace UnityEngine.XR.ARFoundation { /// /// Several method extensions to Pose for inverse-transforming additional Unity types. /// public static class PoseExtensions { /// /// Inversely transform the by Pose. /// /// The Pose to use. /// A position to inversely transform. /// A position inversely transformed by the . public static Vector3 InverseTransformPosition(this Pose pose, Vector3 position) { return Quaternion.Inverse(pose.rotation) * (position - pose.position); } /// /// Inversely transform the by Pose. /// /// The Pose to use. /// A direction to inversely transform. /// A direction inversely transformed by the . public static Vector3 InverseTransformDirection(this Pose pose, Vector3 direction) { return Quaternion.Inverse(pose.rotation) * direction; } /// /// Inversely transform the by Pose. The transform is made in-place. /// /// The Pose to use. /// A List of positions to inversely transform. public static void InverseTransformPositions(this Pose pose, List positions) { if (positions == null) throw new ArgumentNullException("positions"); for (int i = 0; i < positions.Count; ++i) { positions[i] = pose.InverseTransformPosition(positions[i]); } } } }