Esempio n. 1
0
 public Box3f(AxisAlignedBox3f aaBox)
 {
     Extent = 0.5f * aaBox.Diagonal;
     Center = aaBox.Min + Extent;
     AxisX  = Vector3F.AxisX;
     AxisY  = Vector3F.AxisY;
     AxisZ  = Vector3F.AxisZ;
 }
Esempio n. 2
0
        public static AxisAlignedBox3f Bounds <T>(IEnumerable <T> values, Func <T, Vector3F> PositionF)
        {
            AxisAlignedBox3f box = AxisAlignedBox3f.Empty;

            foreach (T t in values)
            {
                box.Contain(PositionF(t));
            }
            return(box);
        }
Esempio n. 3
0
        public AxisAlignedBox3f ToAABB()
        {
            // [TODO] probably more efficient way to do this...at minimum can move center-shift
            // to after the containments...
            Vector3F         extAxis0 = Extent.x * AxisX;
            Vector3F         extAxis1 = Extent.y * AxisY;
            Vector3F         extAxis2 = Extent.z * AxisZ;
            AxisAlignedBox3f result   = new AxisAlignedBox3f(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);
        }