Ejemplo n.º 1
0
 public FixedVector2(Vector3 vector)
 {
     this.rawX = FixedMath.Create(vector.x);
     this.rawY = FixedMath.Create(vector.y);
 }
Ejemplo n.º 2
0
 public FixedVector2(double _x, double _y)
 {
     this.rawX = FixedMath.Create(_x);
     this.rawY = FixedMath.Create(_y);
 }
Ejemplo n.º 3
0
 public FixedVector2(float _x, float _y)
 {
     this.rawX = FixedMath.Create(_x);
     this.rawY = FixedMath.Create(_y);
 }
Ejemplo n.º 4
0
        public static bool AAOrthogonalLineIntersection(FixedLine2 horizontal, FixedLine2 vertical, out FixedVector2 intersection)
        {
            intersection = new FixedVector2(vertical.start.x, horizontal.start.y);

            if ((FixedMath.Min(horizontal.start.x, horizontal.end.x) < intersection.x) && intersection.x < FixedMath.Max(horizontal.start.x, horizontal.end.x) &&
                (FixedMath.Min(vertical.start.y, vertical.end.y) < intersection.y) && intersection.y < FixedMath.Max(vertical.start.y, vertical.end.y))
            {
                return(true);
            }


            //check for sloped lines while accounting for vertical lines
            return(false);
        }
Ejemplo n.º 5
0
        public static bool LineIntersection(FixedVector2 startA, FixedVector2 endA, FixedVector2 startB, FixedVector2 endB, out FixedVector2 intersection)
        {
            intersection = FixedVector2.NAN;

            bool aIsHorizontal, aIsVertical, bIsHorizontal, bIsVertical;

            aIsHorizontal = aIsVertical = bIsHorizontal = bIsVertical = false;


            if (startA.y == endA.y)
            {
                aIsHorizontal = true;
            }
            if (startA.x == endA.x)
            {
                aIsVertical = true;
            }

            if (startB.y == endB.y)
            {
                bIsHorizontal = true;
            }
            if (startB.x == endB.x)
            {
                bIsVertical = true;
            }


            //check if we have parralel lines (even if we have two overlapping lines)
            if ((aIsHorizontal && bIsHorizontal) || ((aIsVertical && bIsVertical)))
            {
                return(false);
            }

            if (aIsHorizontal && bIsVertical)
            {
                intersection = new FixedVector2(startB.x, startA.y);
            }

            else if (bIsHorizontal && aIsVertical)
            {
                intersection = new FixedVector2(startA.x, startB.y);
            }

            if (aIsHorizontal &&
                (FixedMath.Min(startA.x, endA.x) < intersection.x) && intersection.x < FixedMath.Max(startA.x, endA.x) &&
                (FixedMath.Min(startB.y, endB.y) < intersection.y) && intersection.y < FixedMath.Max(startB.y, endB.y))
            {
                return(true);
            }

            if (bIsHorizontal &&
                (FixedMath.Min(startB.x, endB.x) < intersection.x) && intersection.x < FixedMath.Max(startB.x, endB.x) &&
                (FixedMath.Min(startA.y, endA.y) < intersection.y) && intersection.y < FixedMath.Max(startA.y, endA.y))
            {
                return(true);
            }


            //check for sloped lines while accounting for vertical lines
            return(false);
        }
Ejemplo n.º 6
0
        public static bool LineIntersection(FixedLine2 left, FixedLine2 right, out FixedVector2 intersection)
        {
            intersection = FixedVector2.NAN;

            //check if we have parralel lines (even if we have two overlapping lines)
            if ((left.isHorizontal && right.isHorizontal) || ((left.isVertical && right.isVertical)))
            {
                return(false);
            }

            if (left.isHorizontal && right.isVertical)
            {
                horizontal = left;
                vertical   = right;
            }

            else if (right.isHorizontal && left.isVertical)
            {
                horizontal = right;
                vertical   = left;
            }

            intersection = new FixedVector2(vertical.start.x, horizontal.start.y);

            if ((FixedMath.Min(horizontal.start.x, horizontal.end.x) <= intersection.x) && intersection.x <= FixedMath.Max(horizontal.start.x, horizontal.end.x) &&
                (FixedMath.Min(vertical.start.y, vertical.end.y) <= intersection.y) && intersection.y <= FixedMath.Max(vertical.start.y, vertical.end.y))
            {
                return(true);
            }


            //check for sloped lines while accounting for vertical lines
            return(false);
        }