/// <summary> /// Gets the axis aligned bounding box of the orientated shape. /// </summary> /// <param name="orientation">The orientation of the shape.</param> /// <param name="box">The axis aligned bounding box of the shape.</param> public override void GetBoundingBox(ref FPMatrix orientation, out FPBBox box) { FPMatrix abs; FPMath.Absolute(ref orientation, out abs); FPVector temp; FPVector.Transform(ref halfSize, ref abs, out temp); box.max = temp; FPVector.Negate(ref temp, out box.min); }
public void Transform(ref FPMatrix orientation) { FPVector halfExtents = FP.Half * (max - min); FPVector center = FP.Half * (max + min); FPVector.Transform(ref center, ref orientation, out center); FPMatrix abs; FPMath.Absolute(ref orientation, out abs); FPVector.Transform(ref halfExtents, ref abs, out halfExtents); max = center + halfExtents; min = center - halfExtents; }
/// <summary> /// Gets the axis aligned bounding box of the orientated shape. (Inlcuding all /// 'sub' shapes) /// </summary> /// <param name="orientation">The orientation of the shape.</param> /// <param name="box">The axis aligned bounding box of the shape.</param> public override void GetBoundingBox(ref FPMatrix orientation, out TSBBox box) { box.min = mInternalBBox.min; box.max = mInternalBBox.max; FPVector localHalfExtents = FP.Half * (box.max - box.min); FPVector localCenter = FP.Half * (box.max + box.min); FPVector center; FPVector.Transform(ref localCenter, ref orientation, out center); FPMatrix abs; FPMath.Absolute(ref orientation, out abs); FPVector temp; FPVector.Transform(ref localHalfExtents, ref abs, out temp); box.max = center + temp; box.min = center - temp; }
/// <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 FPVector position, ref FPMatrix orientation) { FPVector.Subtract(ref max, ref position, out max); FPVector.Subtract(ref min, ref position, out min); FPVector center; FPVector.Add(ref max, ref min, out center); center.x *= FP.Half; center.y *= FP.Half; center.z *= FP.Half; FPVector halfExtents; FPVector.Subtract(ref max, ref min, out halfExtents); halfExtents.x *= FP.Half; halfExtents.y *= FP.Half; halfExtents.z *= FP.Half; FPVector.TransposedTransform(ref center, ref orientation, out center); FPMatrix abs; FPMath.Absolute(ref orientation, out abs); FPVector.TransposedTransform(ref halfExtents, ref abs, out halfExtents); FPVector.Add(ref center, ref halfExtents, out max); FPVector.Subtract(ref center, ref halfExtents, out min); }