Exemplo n.º 1
0
 public static Point <T> operator /(Point <T> a, T s)
 {
     return(new Point <T>(
                GenericArithmetic <T> .divide(a.x, s),
                GenericArithmetic <T> .divide(a.y, s)
                ));
 }
Exemplo n.º 2
0
 public static Point <T> operator -(Point <T> a, Point <T> b)
 {
     return(new Point <T>(
                GenericArithmetic <T> .substract(a.x, b.x),
                GenericArithmetic <T> .substract(a.y, b.y)
                ));
 }
Exemplo n.º 3
0
 public static Point <T> operator *(Point <T> a, T s)
 {
     return(new Point <T>(
                GenericArithmetic <T> .multiply(a.x, s),
                GenericArithmetic <T> .multiply(a.y, s)
                ));
 }
Exemplo n.º 4
0
 public T cross(Point <T> other)
 {
     return(GenericArithmetic <T> .substract(
                GenericArithmetic <T> .multiply(x, other.y),
                GenericArithmetic <T> .multiply(y, other.x)
                ));
 }
Exemplo n.º 5
0
 public static Point <T> operator +(Point <T> a, Point <T> b)
 {
     return(new Point <T>(
                GenericArithmetic <T> .add(a.x, b.x),
                GenericArithmetic <T> .add(a.y, b.y)
                ));
 }
Exemplo n.º 6
0
 public T dot(Point <T> other)
 {
     return(GenericArithmetic <T> .add(
                GenericArithmetic <T> .multiply(x, other.x),
                GenericArithmetic <T> .multiply(y, other.y)
                ));
 }
Exemplo n.º 7
0
 public static bool operator ==(Rect <T> a, Rect <T> b)
 {
     return(GenericArithmetic <T> .eq(a.x, b.x) &&
            GenericArithmetic <T> .eq(a.y, b.y) &&
            GenericArithmetic <T> .eq(a.width, b.width) &&
            GenericArithmetic <T> .eq(a.height, b.height));
 }
Exemplo n.º 8
0
        public Rect(Point <T> pt1, Point <T> pt2)
        {
            bool xCondition = GenericArithmetic <T> .gt(pt1.x, pt2.x);

            bool yCondition = GenericArithmetic <T> .gt(pt1.x, pt2.x);

            if (xCondition)             // pt1.x > pt2.x
            {
                x     = pt2.x;
                width = GenericArithmetic <T> .substract(pt1.x, pt2.x);
            }
            else
            {
                x     = pt1.x;
                width = GenericArithmetic <T> .substract(pt2.x, pt1.x);
            }

            if (yCondition)             // pt1.y > pt2.y
            {
                y      = pt2.y;
                height = GenericArithmetic <T> .substract(pt1.y, pt2.y);
            }
            else
            {
                y      = pt1.y;
                height = GenericArithmetic <T> .substract(pt2.y, pt1.y);
            }
        }
Exemplo n.º 9
0
        public bool contains(Point <T> pt)
        {
            var br = bottomRight;

            return(!GenericArithmetic <T> .lt(pt.x, x) &&
                   !GenericArithmetic <T> .lt(pt.y, y) &&
                   !GenericArithmetic <T> .gt(pt.x, br.x) &&
                   !GenericArithmetic <T> .gt(pt.y, br.y));
        }
Exemplo n.º 10
0
        public static Rect <T> operator |(Rect <T> a, Rect <T> b)
        {
            var abr = a.bottomRight;
            var bbr = b.bottomRight;
            T   x   = GenericArithmetic <T> .lt(a.x, b.x) ? a.x : b.x;

            T y = GenericArithmetic <T> .lt(a.y, b.y) ? a.y : b.y;

            T w = GenericArithmetic <T> .substract(
                GenericArithmetic <T> .gt(abr.x, bbr.x)?abr.x : bbr.x,
                x);

            T h = GenericArithmetic <T> .substract(
                GenericArithmetic <T> .gt(abr.y, bbr.y)?abr.y : bbr.y,
                y);

            return(new Rect <T>(x, y, w, h));
        }
Exemplo n.º 11
0
 public static bool operator ==(Point <T> a, Point <T> b)
 {
     return(GenericArithmetic <T> .eq(a.x, b.x) &&
            GenericArithmetic <T> .eq(a.y, b.y));
 }