示例#1
0
        public void Transform(ref Matrix3 orientation)
        {
            Vector3 halfExtents = 0.5f * (Max - Min);
            Vector3 center      = 0.5f * (Max + Min);

            Vector3.Transform(ref center, ref orientation, out center);

            Matrix3 abs; JMath.Absolute(ref orientation, out abs);

            Vector3.Transform(ref halfExtents, ref abs, out halfExtents);

            Max = center + halfExtents;
            Min = center - halfExtents;
        }
示例#2
0
        /// <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 Vector3 position, ref Matrix3 orientation)
        {
            Vector3.Subtract(ref Max, ref position, out Max);
            Vector3.Subtract(ref Min, ref position, out Min);

            Vector3 center;

            Vector3.Add(ref Max, ref Min, out center);
            center.X *= 0.5f; center.Y *= 0.5f; center.Z *= 0.5f;

            Vector3 halfExtents;

            Vector3.Subtract(ref Max, ref Min, out halfExtents);
            halfExtents.X *= 0.5f; halfExtents.Y *= 0.5f; halfExtents.Z *= 0.5f;

            Vector3.TransposedTransform(ref center, ref orientation, out center);

            Matrix3 abs; JMath.Absolute(ref orientation, out abs);

            Vector3.TransposedTransform(ref halfExtents, ref abs, out halfExtents);

            Vector3.Add(ref center, ref halfExtents, out Max);
            Vector3.Subtract(ref center, ref halfExtents, out Min);
        }