/// <summary> /// Transforms the bounding box into the space given by orientation and position. /// </summary> /// <param name="position"></param> /// <param name="orientation"></param> /// <param name="result"></param> internal void InverseTransform(ref TSVector position, ref TSMatrix orientation) { TSVector.Subtract(ref max, ref position, out max); TSVector.Subtract(ref min, ref position, out min); TSVector center; TSVector.Add(ref max, ref min, out center); center.x *= FP.Half; center.y *= FP.Half; center.z *= FP.Half; TSVector halfExtents; TSVector.Subtract(ref max, ref min, out halfExtents); halfExtents.x *= FP.Half; halfExtents.y *= FP.Half; halfExtents.z *= FP.Half; TSVector.TransposedTransform(ref center, ref orientation, out center); TSMatrix abs; TSMath.Absolute(ref orientation, out abs); TSVector.TransposedTransform(ref halfExtents, ref abs, out halfExtents); TSVector.Add(ref center, ref halfExtents, out max); TSVector.Subtract(ref center, ref halfExtents, out min); }
/// <summary> /// Transforms the bounding box into the space given by orientation and position. /// </summary> /// <param name="position"></param> /// <param name="orientation"></param> /// <param name="result"></param> internal void InverseTransform(TSVector position, TSMatrix orientation) { TSVector.Subtract(max, position, out max); TSVector.Subtract(min, position, out min); TSVector center; TSVector.Add(max, min, out center); center.x *= FP.Half; center.y *= FP.Half; center.z *= FP.Half; TSVector halfExtents; TSVector.Subtract(max, min, out halfExtents); halfExtents.x *= FP.Half; halfExtents.y *= FP.Half; halfExtents.z *= FP.Half; TSVector.TransposedTransform(center, orientation, out center); TSMatrix abs; TSMath.Absolute(orientation, out abs); TSVector.TransposedTransform(halfExtents, abs, out halfExtents); TSVector.Add(center, halfExtents, out max); TSVector.Subtract(center, halfExtents, out min); }