/// <summary>
        /// Appends the interval passed in, conserves this axis.
        /// </summary>
        /// <param name="inter"></param>
        public void Concat(AxisInterval inter)
        {
            var a = Mathf.Min(this.Min, inter.Min);
            var b = Mathf.Max(this.Max, inter.Max);

            this.SetExtents(a, b);
        }
 /// <summary>
 /// Tests if Min and Max intersects, ignores axis
 /// </summary>
 /// <param name="inter"></param>
 /// <returns></returns>
 public bool Intersects(AxisInterval inter)
 {
     if (_max < inter.Min)
     {
         return(false);
     }
     if (_min > inter.Max)
     {
         return(false);
     }
     return(true);
 }
Exemple #3
0
        public AxisInterval Project(Vector3 axis)
        {
            if (_geom == null)
            {
                this.UpdateGeom();
                if (_geom == null)
                {
                    return(AxisInterval.NoHit(axis));
                }
            }

            return(_geom.Project(axis));
        }
        /// <summary>
        /// Total distance the two intervals pass, ignores axis
        /// </summary>
        /// <param name="inter"></param>
        /// <returns></returns>
        public float Distance(AxisInterval inter)
        {
            if (_max > inter.Min)
            {
                return(0);
            }
            if (_min < inter.Max)
            {
                return(0);
            }

            return(Mathf.Abs(_max - inter.Min));
        }
        /// <summary>
        /// Get the interval intersection of this and another interval, conserves this axis.
        /// </summary>
        /// <param name="inter"></param>
        /// <returns></returns>
        public AxisInterval Intersection(AxisInterval inter)
        {
            if (_max < inter.Min)
            {
                return(new AxisInterval(_axis, 0, 0));
            }
            if (_min > inter.Max)
            {
                return(new AxisInterval(_axis, 0, 0));
            }

            return(new AxisInterval(_axis, Mathf.Max(_min, inter.Min), Mathf.Min(_max, inter.Max)));
        }
        /// <summary>
        /// Total distance the two intervals pass, ignores axis
        /// </summary>
        /// <param name="inter"></param>
        /// <returns></returns>
        public float Distance(AxisInterval inter)
        {
            if (_max > inter.Min) return 0;
            if (_min < inter.Max) return 0;

            return Mathf.Abs(_max - inter.Min);
        }
 /// <summary>
 /// Appends the interval passed in, conserves this axis.
 /// </summary>
 /// <param name="inter"></param>
 public void Concat(AxisInterval inter)
 {
     var a = Mathf.Min(this.Min, inter.Min);
     var b = Mathf.Max(this.Max, inter.Max);
     this.SetExtents(a, b);
 }
 /// <summary>
 /// Finds the mid value of the Min and Max of both intervals, ignores axis
 /// </summary>
 /// <param name="inter"></param>
 /// <returns></returns>
 public float MidValue(AxisInterval inter)
 {
     float[] arr = new float[] { _min, _max, inter.Min, inter.Max };
     System.Array.Sort(arr);
     return (arr[2] + arr[1]) / 2.0f;
 }
 /// <summary>
 /// Tests if Min and Max intersects, ignores axis
 /// </summary>
 /// <param name="inter"></param>
 /// <returns></returns>
 public bool Intersects(AxisInterval inter)
 {
     if (_max < inter.Min) return false;
     if (_min > inter.Max) return false;
     return true;
 }
        /// <summary>
        /// Get the interval intersection of this and another interval, conserves this axis.
        /// </summary>
        /// <param name="inter"></param>
        /// <returns></returns>
        public AxisInterval Intersection(AxisInterval inter)
        {
            if (_max < inter.Min) return new AxisInterval(_axis, 0, 0);
            if (_min > inter.Max) return new AxisInterval(_axis, 0, 0);

            return new AxisInterval(_axis, Mathf.Max(_min, inter.Min), Mathf.Min(_max, inter.Max));
        }
 /// <summary>
 /// Finds the mid value of the Min and Max of both intervals, ignores axis
 /// </summary>
 /// <param name="inter"></param>
 /// <returns></returns>
 public float MidValue(AxisInterval inter)
 {
     float[] arr = new float[] { _min, _max, inter.Min, inter.Max };
     System.Array.Sort(arr);
     return((arr[2] + arr[1]) / 2.0f);
 }