Example #1
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)
                ));
 }
Example #2
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);
            }
        }
Example #3
0
 public T cross(Point <T> other)
 {
     return(GenericArithmetic <T> .substract(
                GenericArithmetic <T> .multiply(x, other.y),
                GenericArithmetic <T> .multiply(y, other.x)
                ));
 }
Example #4
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));
        }