//copy constructor
 public Segment(Segment cpy)
 {
     startX = cpy.StartX;
     endX = cpy.EndX;
     startY = cpy.StartY;
     endY = cpy.EndY;
     m = cpy.getM();
     b = cpy.getB();
     lX = cpy.getLX();
     hY = cpy.getHY();
     lY = cpy.getLY();
     hX = cpy.getHX();
     vert = cpy.isVert();
 }
        //checks if segments intersect on given interval
        //xaxis indicates direction of movement respective to x axis
        public bool intersect(Segment inter, bool xaxis)
        {
            float interX;
            //returns false if lines are parallel
            if ((inter.getM() == m && inter.getB() == b) || (Single.IsPositiveInfinity(inter.getM()) && Single.IsPositiveInfinity(m)))
            {
                if((m == 0 && xaxis) && (lY == inter.getLY() && (startX < inter.getHX() && startX > inter.getLX())))
                {
                    return true;
                }
                else if((vert && !xaxis) && (lX == inter.getLX() && (startY < inter.getHY() && startY > inter.getLY())))
                {
                    return true;
                }
                return false;
            }
            //if one of the segments is verticle, chacks if second segment intersects it
            if (vert)
            {
                //makes sure the segments intersect on the x and y axis
                if ((startX < inter.getHX() && startX > inter.getLX()) && (hY > inter.getLY() && lY < inter.getHY()))
                {
                    return true;
                }
            }
            else if (inter.isVert())
            {
                //makes sure the segments intersect on the x and y axis
                if ((inter.startX < hX && inter.startX > lX) && (inter.getHY() > lY && inter.getLY() < hY))
                {
                    return true;
                }
            }
            //else determines point of intersection based on m and b values and checks if intersection on interval bounded by the segments
            else
            {
                interX = (b - inter.b) / (inter.m - m);
                if (interX > lX && interX < hX)
                {
                    return true;
                }
            }

            return false;
        }