BEPUphysics.CollisionShapes.ConvexShapes.BoxShape.GetBoundingBox C# (CSharp) Метод

GetBoundingBox() публичный Метод

Gets the bounding box of the shape given a transform.
public GetBoundingBox ( RigidTransform &shapeTransform, BEPUutilities.BoundingBox &boundingBox ) : void
shapeTransform BEPUutilities.RigidTransform Transform to use.
boundingBox BEPUutilities.BoundingBox Bounding box of the transformed shape.
Результат void
        public override void GetBoundingBox(ref RigidTransform shapeTransform, out BoundingBox boundingBox)
        {
#if !WINDOWS
            boundingBox = new BoundingBox();
#endif

            Matrix3x3 o;
            Matrix3x3.CreateFromQuaternion(ref shapeTransform.Orientation, out o);
            //Sample the local directions from the orientation matrix, implicitly transposed.
            //Notice only three directions are used.  Due to box symmetry, 'left' is just -right.
            var right = new Vector3(Math.Sign(o.M11) * halfWidth, Math.Sign(o.M21) * halfHeight, Math.Sign(o.M31) * halfLength);

            var up = new Vector3(Math.Sign(o.M12) * halfWidth, Math.Sign(o.M22) * halfHeight, Math.Sign(o.M32) * halfLength);

            var backward = new Vector3(Math.Sign(o.M13) * halfWidth, Math.Sign(o.M23) * halfHeight, Math.Sign(o.M33) * halfLength);

            Matrix3x3.Transform(ref right, ref o, out right);
            Matrix3x3.Transform(ref up, ref o, out up);
            Matrix3x3.Transform(ref backward, ref o, out backward);
            //These right/up/backward represent the extreme points in world space along the world space axes.

            boundingBox.Max.X = shapeTransform.Position.X + right.X;
            boundingBox.Max.Y = shapeTransform.Position.Y + up.Y;
            boundingBox.Max.Z = shapeTransform.Position.Z + backward.Z;

            boundingBox.Min.X = shapeTransform.Position.X - right.X;
            boundingBox.Min.Y = shapeTransform.Position.Y - up.Y;
            boundingBox.Min.Z = shapeTransform.Position.Z - backward.Z;

        }