/// <summary>
 /// Check if this RectCollider is colliding with the given SegmentCollider.
 /// </summary>
 /// <param name="segment"></param>
 /// <returns></returns>
 public CollisionResponse CollidingWith(SegmentCollider segment)
 {
     var intersections = new List<Vector2>();
     var corners = Coords;
     Vector2 p1, p2;
     Vector2? poi;
     for (int i = 0; i < 4; i++)
     {
         p1 = corners[(i - 1) % 4];
         p2 = corners[i];
         poi = LinearUtils.SegmentIntersectionPoint(
             p1.X, p1.Y, p2.X, p2.Y,
             segment.Start.X, segment.Start.Y,
             segment.End.X, segment.End.Y
             );
         if (poi.HasValue)
             intersections.Add(poi.Value);
     }
     var c_res = new CollisionResponse(this, segment, intersections.Count > 0);
     if (!c_res.Colliding)
         return c_res;
     c_res.SetAttr<Vector2[]>("Intersections", intersections.ToArray());
     return c_res;
 }
        /// <summary>
        /// Check if this EllipseCollider is colliding with the given SegmentCollider.
        /// </summary>
        /// <param name="segment"></param>
        /// <returns></returns>
        public CollisionResponse CollidingWith(SegmentCollider segment)
        {
            var c_res = new CollisionResponse(this, segment, false);
            double X1 = segment.Start.X,
                   X2 = segment.End.X,
                   Y1 = segment.Start.Y,
                   Y2 = segment.End.Y;
            var intersections = EllipseUtils.EllipseLineIntersections(X, Y, A, B, X1, Y1, X2, Y2);
            if (intersections.Length == 0)
                return c_res;

            var valid = new List<Vector2>();
            foreach (var poi in intersections)
            {
                if (LinearUtils.IsPointInSegmentRange(
                        poi.X, poi.Y, X1, Y1, X2, Y2))
                    valid.Add(poi);
            }

            var count = valid.Count;
            if (count == 0)
                return c_res;

            c_res.SetAttr<int>("NumIntersections", count);
            c_res.SetAttr<Vector2[]>("IntersectionPoints", valid.ToArray());

            return c_res;
        }
 /// <summary>
 /// Check if this SegmentCollider is colliding with the given SegmentCollider.
 /// </summary>
 /// <param name="segment"></param>
 /// <returns></returns>
 public CollisionResponse CollidingWith(SegmentCollider segment)
 {
     var poi = LinearUtils.SegmentIntersectionPoint(
         Start.X, Start.Y, End.X, End.Y, segment.Start.X,
         segment.Start.Y, segment.End.X, segment.End.Y
         );
     var c_res = new CollisionResponse(this, segment, poi.HasValue);
     if (!c_res.Colliding)
         return c_res;
     c_res.SetAttr<Vector2>("IntersectionPoint", poi.Value);
     return c_res;
 }