PixelFarm.VectorMath.AxisAlignedBoundingBox.NewTransformed C# (CSharp) Method

NewTransformed() public method

public NewTransformed ( Matrix4X4 transform ) : AxisAlignedBoundingBox
transform Matrix4X4
return AxisAlignedBoundingBox
        public AxisAlignedBoundingBox NewTransformed(Matrix4X4 transform)
        {
            Vector3[] boundsVerts = new Vector3[8];
            boundsVerts[0] = new Vector3(this[0][0], this[0][1], this[0][2]);
            boundsVerts[1] = new Vector3(this[0][0], this[0][1], this[1][2]);
            boundsVerts[2] = new Vector3(this[0][0], this[1][1], this[0][2]);
            boundsVerts[3] = new Vector3(this[0][0], this[1][1], this[1][2]);
            boundsVerts[4] = new Vector3(this[1][0], this[0][1], this[0][2]);
            boundsVerts[5] = new Vector3(this[1][0], this[0][1], this[1][2]);
            boundsVerts[6] = new Vector3(this[1][0], this[1][1], this[0][2]);
            boundsVerts[7] = new Vector3(this[1][0], this[1][1], this[1][2]);
            Vector3.Transform(boundsVerts, transform);
            Vector3 newMin = new Vector3(double.MaxValue, double.MaxValue, double.MaxValue);
            Vector3 newMax = new Vector3(double.MinValue, double.MinValue, double.MinValue);
            for (int i = 0; i < 8; i++)
            {
                newMin.x = Math.Min(newMin.x, boundsVerts[i].x);
                newMin.y = Math.Min(newMin.y, boundsVerts[i].y);
                newMin.z = Math.Min(newMin.z, boundsVerts[i].z);
                newMax.x = Math.Max(newMax.x, boundsVerts[i].x);
                newMax.y = Math.Max(newMax.y, boundsVerts[i].y);
                newMax.z = Math.Max(newMax.z, boundsVerts[i].z);
            }

            return new AxisAlignedBoundingBox(newMin, newMax);
        }