Example #1
0
        public static AxisAlignedBox3d Bounds(IPointSet source)
        {
            AxisAlignedBox3d bounds = AxisAlignedBox3d.Empty;

            foreach (int vid in source.VertexIndices())
            {
                bounds.Contain(source.GetVertex(vid));
            }
            return(bounds);
        }
Example #2
0
        public static AxisAlignedBox3d Bounds <T>(IEnumerable <T> values, Func <T, Vector3D> PositionF)
        {
            AxisAlignedBox3d box = AxisAlignedBox3d.Empty;

            foreach (T t in values)
            {
                box.Contain(PositionF(t));
            }
            return(box);
        }
Example #3
0
        /// <summary>
        /// compute axis-aligned bounds of set of points after transforming into frame f
        /// </summary>
        public static AxisAlignedBox3d BoundsInFrame(IEnumerable <Vector3D> values, Frame3f f)
        {
            AxisAlignedBox3d box = AxisAlignedBox3d.Empty;

            foreach (Vector3D v in values)
            {
                box.Contain(f.ToFrameP(v));
            }
            return(box);
        }
Example #4
0
        // AABB of transformed AABB (corners)
        public static AxisAlignedBox3d Bounds(ref AxisAlignedBox3d boxIn, Func <Vector3D, Vector3D> TransformF)
        {
            if (TransformF == null)
            {
                return(boxIn);
            }

            AxisAlignedBox3d box = new AxisAlignedBox3d(TransformF(boxIn.Corner(0)));

            for (int i = 1; i < 8; ++i)
            {
                box.Contain(TransformF(boxIn.Corner(i)));
            }
            return(box);
        }
Example #5
0
        public AxisAlignedBox3d ToAABB()
        {
            // [TODO] probably more efficient way to do this...at minimum can move center-shift
            // to after the containments...
            Vector3D         extAxis0 = Extent.x * AxisX;
            Vector3D         extAxis1 = Extent.y * AxisY;
            Vector3D         extAxis2 = Extent.z * AxisZ;
            AxisAlignedBox3d result   = new AxisAlignedBox3d(Center - extAxis0 - extAxis1 - extAxis2);

            result.Contain(Center + extAxis0 - extAxis1 - extAxis2);
            result.Contain(Center + extAxis0 + extAxis1 - extAxis2);
            result.Contain(Center - extAxis0 + extAxis1 - extAxis2);
            result.Contain(Center - extAxis0 - extAxis1 + extAxis2);
            result.Contain(Center + extAxis0 - extAxis1 + extAxis2);
            result.Contain(Center + extAxis0 + extAxis1 + extAxis2);
            result.Contain(Center - extAxis0 + extAxis1 + extAxis2);
            return(result);
        }