public Box3(AAB3 box)
 {
     box.CalcCenterExtents(out this.Center, out this.Extents);
     this.Axis0 = Vector3ex.UnitX;
     this.Axis1 = Vector3ex.UnitY;
     this.Axis2 = Vector3ex.UnitZ;
 }
Пример #2
0
        public bool QuerySidePositive(ref AAB3 box, float epsilon = 1E-05f)
        {
            Vector3 value;

            if (this.Normal.x >= 0f)
            {
                value.x = box.Min.x;
            }
            else
            {
                value.x = box.Max.x;
            }
            if (this.Normal.y >= 0f)
            {
                value.y = box.Min.y;
            }
            else
            {
                value.y = box.Max.y;
            }
            if (this.Normal.z >= 0f)
            {
                value.z = box.Min.z;
            }
            else
            {
                value.z = box.Max.z;
            }
            return(this.Normal.Dot(value) - this.Constant >= -epsilon);
        }
Пример #3
0
        public static AAB3 CreateFromPoints(Vector3[] points)
        {
            int num = points.Length;

            if (num > 0)
            {
                AAB3 result = AAB3.CreateFromPoint(ref points[0]);
                for (int i = 1; i < num; i++)
                {
                    result.Include(ref points[i]);
                }
                return(result);
            }
            return(default(AAB3));
        }
Пример #4
0
        public static AAB3 CreateFromPoints(IList <Vector3> points)
        {
            int count = points.Count;

            if (count > 0)
            {
                AAB3 result = AAB3.CreateFromPoint(points[0]);
                for (int i = 1; i < count; i++)
                {
                    result.Include(points[i]);
                }
                return(result);
            }
            return(default(AAB3));
        }
Пример #5
0
        public static Sphere3 CreateFromPointsAAB(IList <Vector3> points)
        {
            if (points.Count == 0)
            {
                return(default(Sphere3));
            }
            Vector3 center;
            Vector3 vector;

            AAB3.CreateFromPoints(points).CalcCenterExtents(out center, out vector);
            Sphere3 result;

            result.Center = center;
            result.Radius = vector.magnitude;
            return(result);
        }
            public Data(Vector3[] points, float radius, Rand rand, AAB3 aab)
            {
                _min = aab.Min;
                _max = aab.Max;
                Vector3 size = _max - _min;

                _radius = radius;

                _cellSize = radius / Mathf.Sqrt(3.0f);
                _cellsX   = Mathf.CeilToInt(size.x / _cellSize);
                _cellsY   = Mathf.CeilToInt(size.y / _cellSize);
                _cellsZ   = Mathf.CeilToInt(size.z / _cellSize);

                _points = points;
                _grid   = new List <int> [_cellsX, _cellsY, _cellsZ];
                _rand   = rand;
            }
Пример #7
0
        public static AAB3 CreateFromPoints(IEnumerable <Vector3> points)
        {
            IEnumerator <Vector3> enumerator = points.GetEnumerator();

            enumerator.Reset();
            if (!enumerator.MoveNext())
            {
                return(default(AAB3));
            }
            AAB3 result = AAB3.CreateFromPoint(enumerator.Current);

            while (enumerator.MoveNext())
            {
                result.Include(enumerator.Current);
            }
            return(result);
        }
Пример #8
0
        public int QuerySide(ref AAB3 box, float epsilon = 1E-05f)
        {
            Vector3 value;
            Vector3 value2;

            if (this.Normal.x >= 0f)
            {
                value.x  = box.Min.x;
                value2.x = box.Max.x;
            }
            else
            {
                value.x  = box.Max.x;
                value2.x = box.Min.x;
            }
            if (this.Normal.y >= 0f)
            {
                value.y  = box.Min.y;
                value2.y = box.Max.y;
            }
            else
            {
                value.y  = box.Max.y;
                value2.y = box.Min.y;
            }
            if (this.Normal.z >= 0f)
            {
                value.z  = box.Min.z;
                value2.z = box.Max.z;
            }
            else
            {
                value.z  = box.Max.z;
                value2.z = box.Min.z;
            }
            if (this.Normal.Dot(value) - this.Constant > -epsilon)
            {
                return(1);
            }
            if (this.Normal.Dot(value2) - this.Constant < epsilon)
            {
                return(-1);
            }
            return(0);
        }
Пример #9
0
        public static Sphere3 CreateFromPointsAAB(IEnumerable <Vector3> points)
        {
            IEnumerator <Vector3> enumerator = points.GetEnumerator();

            enumerator.Reset();
            if (!enumerator.MoveNext())
            {
                return(default(Sphere3));
            }
            Vector3 center;
            Vector3 vector;

            AAB3.CreateFromPoints(points).CalcCenterExtents(out center, out vector);
            Sphere3 result;

            result.Center = center;
            result.Radius = vector.magnitude;
            return(result);
        }
        public static List <int> DistanceFilter(Vector3[] points, AAB3 pointsAAB, float radius, Rand rand)
        {
            Data data = new Data(points, radius, rand, pointsAAB);

            return(data.Filter());
        }
Пример #11
0
 public void Include(AAB3 box)
 {
     this.Include(ref box.Min);
     this.Include(ref box.Max);
 }
Пример #12
0
 public static AAB3 CreateFromTwoPoints(Vector3 point0, Vector3 point1)
 {
     return(AAB3.CreateFromTwoPoints(ref point0, ref point1));
 }