public void TestCloseMiss()
 {
     Assert.IsFalse(
         Line2Disc2Collider.FindContacts(
             new Vector2(-1.0f, 2.1f), Vector2.UnitX, 2.0f
             ).HasContact
         );
 }
        public void TestLineThroughCenter()
        {
            LineContacts contacts = Line2Disc2Collider.FindContacts(
                new Vector2(-3.0f, 0.0f), Vector2.UnitX, 2.0f
                );

            Assert.That(
                contacts.EntryTime,
                Is.EqualTo(1.0f).Within(Specifications.MaximumDeviation).Ulps
                );
            Assert.That(
                contacts.ExitTime,
                Is.EqualTo(5.0f).Within(Specifications.MaximumDeviation).Ulps
                );
        }
        public void TestCircleWithAbsolutePosition()
        {
            Vector2      unitDiagonal = Vector2.Normalize(Vector2.One);
            LineContacts contacts     = Line2Disc2Collider.FindContacts(
                Vector2.Zero, unitDiagonal, unitDiagonal * 5.0f, 2.0f
                );

            Assert.That(
                contacts.EntryTime,
                Is.EqualTo(3.0f).Within(Specifications.MaximumDeviation).Ulps
                );
            Assert.That(
                contacts.ExitTime,
                Is.EqualTo(7.0f).Within(Specifications.MaximumDeviation).Ulps
                );
        }
        /// <summary>Determines where a ray will hit a disc, if at all</summary>
        /// <param name="rayStart">Starting point of the ray</param>
        /// <param name="rayDirection">Direction into which the ray extends</param>
        /// <param name="discCenter">Center of the disc</param>
        /// <param name="discRadius">Radius of the disc</param>
        /// <returns>The intersection points between the ray and the box, if any</returns>
        public static LineContacts FindContacts(
            Vector2 rayStart, Vector2 rayDirection, Vector2 discCenter, float discRadius
            )
        {
            LineContacts contacts = Line2Disc2Collider.FindContacts(
                rayStart, rayDirection, discCenter, discRadius
                );

            // If the line has entered the box before the reference point, this means
            // that the ray starts within the box, thus, its first contact occurs immediately
            if (!float.IsNaN(contacts.EntryTime))
            {
                if (contacts.ExitTime < 0.0f) // Entry & exit before the ray's beginning?
                {
                    return(LineContacts.None);
                }
                else if (contacts.EntryTime < 0.0f) // Only entry before ray's beginning?
                {
                    contacts.EntryTime = 0.0f;
                }
            }

            return(contacts);
        }