示例#1
0
 /// <summary>
 ///   <para></para>
 /// </summary>
 /// <param name="source"></param>
 public FixedRect(FixedRect source)
 {
     this.m_XMin   = source.m_XMin;
     this.m_YMin   = source.m_YMin;
     this.m_Width  = source.m_Width;
     this.m_Height = source.m_Height;
 }
示例#2
0
        /// <summary>
        ///   <para>Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.</para>
        /// </summary>
        /// <param name="other">Other rectangle to test overlapping with.</param>
        /// <param name="allowInverse">Does the test allow the widths and heights of the Rects to be negative?</param>
        public bool Overlaps(FixedRect other, bool allowInverse)
        {
            FixedRect rect = this;

            if (allowInverse)
            {
                rect  = FixedRect.OrderMinMax(rect);
                other = FixedRect.OrderMinMax(other);
            }
            return(rect.Overlaps(other));
        }
示例#3
0
 private static FixedRect OrderMinMax(FixedRect rect)
 {
     if ((Fixed)rect.xMin > (Fixed)rect.xMax)
     {
         Fixed xMin = rect.xMin;
         rect.xMin = rect.xMax;
         rect.xMax = xMin;
     }
     if ((Fixed)rect.yMin > (Fixed)rect.yMax)
     {
         Fixed yMin = rect.yMin;
         rect.yMin = rect.yMax;
         rect.yMax = yMin;
     }
     return(rect);
 }
示例#4
0
    public static bool PositionIsInRect(FixedRect rect, Vector3d basePosition, FixedQuaternion baseQuaternion, Vector3d posi)
    {
#if UNITY_EDITOR
        Vector3d leftDown  = baseQuaternion * (new Vector3d(rect.center) + new Vector3d(-rect.width / 2, 0, -rect.height / 2)) + basePosition;
        Vector3d rightDown = baseQuaternion * (new Vector3d(rect.center) + new Vector3d(rect.width / 2, 0, -rect.height / 2)) + basePosition;
        Vector3d leftUp    = baseQuaternion * (new Vector3d(rect.center) + new Vector3d(-rect.width / 2, 0, rect.height / 2)) + basePosition;
        Vector3d rightUp   = baseQuaternion * (new Vector3d(rect.center) + new Vector3d(rect.width / 2, 0, rect.height / 2)) + basePosition;

        Debug.DrawLine(leftDown.ToVector3(), leftUp.ToVector3(), Color.green, 1);
        Debug.DrawLine(leftUp.ToVector3(), rightUp.ToVector3(), Color.green, 1);
        Debug.DrawLine(rightUp.ToVector3(), rightDown.ToVector3(), Color.green, 1);
        Debug.DrawLine(rightDown.ToVector3(), leftDown.ToVector3(), Color.green, 1);
#endif
        var relativeP       = posi - basePosition;
        var rotateRelativeP = FixedQuaternion.Inverse(baseQuaternion) * relativeP;
        return(rect.ContainsPoint(rotateRelativeP));
    }
示例#5
0
 /// <summary>
 ///   <para>Returns a point inside a rectangle, given normalized coordinates.</para>
 /// </summary>
 /// <param name="rectangle">Rectangle to get a point inside.</param>
 /// <param name="normalizedRectCoordinates">Normalized coordinates to get a point for.</param>
 public static FixedVector2 NormalizedToPoint(FixedRect rectangle, FixedVector2 normalizedRectCoordinates)
 {
     return(new FixedVector2(FixedMathf.Lerp(rectangle.x, rectangle.xMax, normalizedRectCoordinates.x), FixedMathf.Lerp(rectangle.y, rectangle.yMax, normalizedRectCoordinates.y)));
 }
示例#6
0
 /// <summary>
 ///   <para>Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.</para>
 /// </summary>
 /// <param name="other">Other rectangle to test overlapping with.</param>
 /// <param name="allowInverse">Does the test allow the widths and heights of the Rects to be negative?</param>
 public bool Overlaps(FixedRect other)
 {
     return((Fixed)other.xMax > (Fixed)this.xMin && (Fixed)other.xMin < (Fixed)this.xMax && (Fixed)other.yMax > (Fixed)this.yMin && (Fixed)other.yMin < (Fixed)this.yMax);
 }