public void TestFullConstructor() {
      LineContacts contacts = new LineContacts(12.34f, 56.78f);

      Assert.IsTrue(contacts.HasContact);
      Assert.AreEqual(12.34f, contacts.EntryTime);
      Assert.AreEqual(56.78f, contacts.ExitTime);
    }
    public void TestSingleContactConstructor() {
      LineContacts contacts = new LineContacts(123.456f);

      Assert.IsTrue(contacts.HasContact);
      Assert.AreEqual(123.456f, contacts.EntryTime);
      Assert.AreEqual(123.456f, contacts.ExitTime);
    }
Esempio n. 3
0
        public void TestGetHashCode()
        {
            LineContacts contacts1 = new LineContacts(12.34f, 56.78f);
            LineContacts contacts2 = new LineContacts(12.34f, 56.78f);

            Assert.AreEqual(contacts1.GetHashCode(), contacts2.GetHashCode());
        }
Esempio n. 4
0
        /// <summary>
        ///   Limits the contact positions found in a line to the subsection of
        ///   the line covered by the line segment
        /// </summary>
        /// <param name="contacts">Contacts that will be limited to the line segment</param>
        private static void limitContactToLineSegment(ref LineContacts contacts)
        {
            if (!float.IsNaN(contacts.EntryTime))
            {
                bool contactLiesOutsideOfSegment =
                    (contacts.EntryTime > 1.0f) ||
                    (contacts.ExitTime < 0.0f);

                if (contactLiesOutsideOfSegment)
                {
                    contacts.EntryTime = float.NaN;
                    contacts.ExitTime  = float.NaN;
                }
                else
                {
                    if (contacts.EntryTime < 0.0f)
                    {
                        contacts.EntryTime = 0.0f;
                    }
                    if (contacts.ExitTime > 1.0f)
                    {
                        contacts.ExitTime = 1.0f;
                    }
                }
            }
        }
    public void TestEqualityComparison() {
      LineContacts contacts = new LineContacts(12.34f, 56.78f);
      LineContacts identical = new LineContacts(12.34f, 56.78f);
      LineContacts different = new LineContacts(56.78f, 12.34f);

      Assert.IsTrue(contacts.Equals(identical));
      Assert.IsFalse(contacts.Equals(different));
    }
Esempio n. 6
0
        public void TestSingleContactConstructor()
        {
            LineContacts contacts = new LineContacts(123.456f);

            Assert.IsTrue(contacts.HasContact);
            Assert.AreEqual(123.456f, contacts.EntryTime);
            Assert.AreEqual(123.456f, contacts.ExitTime);
        }
Esempio n. 7
0
        public void TestFullConstructor()
        {
            LineContacts contacts = new LineContacts(12.34f, 56.78f);

            Assert.IsTrue(contacts.HasContact);
            Assert.AreEqual(12.34f, contacts.EntryTime);
            Assert.AreEqual(56.78f, contacts.ExitTime);
        }
Esempio n. 8
0
File: Ray3.cs Progetto: minskowl/MY
        /// <summary>Determines where the range clips a triangle</summary>
        /// <param name="triangle">Triangle that will be checked for intersection</param>
        /// <returns>The times at which the range touches the triangle, if at all</returns>
        public LineContacts FindContacts(Triangle3 triangle)
        {
            LineContacts contacts = Collisions.Line3Triangle3Collider.FindContacts(
                Origin, Direction, triangle.A, triangle.B, triangle.C
                );

            limitContactToRay(ref contacts);
            return(contacts);
        }
Esempio n. 9
0
        public void TestEqualityComparison()
        {
            LineContacts contacts  = new LineContacts(12.34f, 56.78f);
            LineContacts identical = new LineContacts(12.34f, 56.78f);
            LineContacts different = new LineContacts(56.78f, 12.34f);

            Assert.IsTrue(contacts.Equals(identical));
            Assert.IsFalse(contacts.Equals(different));
        }
Esempio n. 10
0
File: Ray3.cs Progetto: minskowl/MY
        /// <summary>Determines where the range clips a plane</summary>
        /// <param name="plane">Plane that will be checked for intersection</param>
        /// <returns>The times at which the range touches the plane, if at all</returns>
        public LineContacts FindContacts(Plane3 plane)
        {
            LineContacts contacts = Collisions.Line3Plane3Collider.FindContacts(
                Origin, Direction, plane.Offset, plane.Normal
                );

            limitContactToRay(ref contacts);
            return(contacts);
        }
Esempio n. 11
0
        /// <summary>Determines where the range clips a plane</summary>
        /// <param name="plane">Plane that will be checked for intersection</param>
        /// <returns>The times at which the range touches the plane, if at all</returns>
        public LineContacts FindContacts(Plane3 plane)
        {
            LineContacts contacts = Collisions.Line3Plane3Collider.FindContacts(
                Start, End - Start, plane.Offset, plane.Normal
                );

            limitContactToLineSegment(ref contacts);

            return(contacts);
        }
Esempio n. 12
0
        /// <summary>Determines where the range clips a triangle</summary>
        /// <param name="triangle">Triangle that will be checked for intersection</param>
        /// <returns>The times at which the range touches the triangle, if at all</returns>
        public LineContacts FindContacts(Triangle3 triangle)
        {
            LineContacts contacts = Collisions.Line3Triangle3Collider.FindContacts(
                Start, End - Start, triangle.A, triangle.B, triangle.C
                );

            limitContactToLineSegment(ref contacts);

            return(contacts);
        }
Esempio n. 13
0
        /// <summary>
        ///   Determines whether this instance is identical to another instance
        /// </summary>
        /// <param name="otherObject">Other instance of compare against</param>
        /// <returns>True if both instances are identical</returns>
        public override bool Equals(object otherObject)
        {
            if (!(otherObject is LineContacts))
            {
                return(false);
            }

            LineContacts other = (LineContacts)otherObject;

            return
                ((this.EntryTime == other.EntryTime) &&
                 (this.ExitTime == other.ExitTime));
        }
Esempio n. 14
0
File: Ray3.cs Progetto: minskowl/MY
        /// <summary>
        ///   Limits the contact positions found in a line to the subsection of
        ///   the line covered by the line segment
        /// </summary>
        /// <param name="contacts">Contacts that will be limited to the line segment</param>
        private static void limitContactToRay(ref LineContacts contacts)
        {
            if (!float.IsNaN(contacts.EntryTime))
            {
                bool contactLiesOutsideOfRay =
                    (contacts.ExitTime < 0.0f);

                if (contactLiesOutsideOfRay)
                {
                    contacts.EntryTime = float.NaN;
                    contacts.ExitTime  = float.NaN;
                }
                else
                {
                    if (contacts.EntryTime < 0.0f)
                    {
                        contacts.EntryTime = 0.0f;
                    }
                }
            }
        }
Esempio n. 15
0
    /// <summary>
    ///   Limits the contact positions found in a line to the subsection of
    ///   the line covered by the line segment
    /// </summary>
    /// <param name="contacts">Contacts that will be limited to the line segment</param>
    private static void limitContactToLineSegment(ref LineContacts contacts) {
      if(!float.IsNaN(contacts.EntryTime)) {
        bool contactLiesOutsideOfSegment =
          (contacts.EntryTime > 1.0f) ||
          (contacts.ExitTime < 0.0f);

        if(contactLiesOutsideOfSegment) {
          contacts.EntryTime = float.NaN;
          contacts.ExitTime = float.NaN;
        } else {
          if(contacts.EntryTime < 0.0f) {
            contacts.EntryTime = 0.0f;
          }
          if(contacts.ExitTime > 1.0f) {
            contacts.ExitTime = 1.0f;
          }
        }
      }
    }
Esempio n. 16
0
    public void TestGetHashCode() {
      LineContacts contacts1 = new LineContacts(12.34f, 56.78f);
      LineContacts contacts2 = new LineContacts(12.34f, 56.78f);

      Assert.AreEqual(contacts1.GetHashCode(), contacts2.GetHashCode());
    }
Esempio n. 17
0
    /// <summary>
    ///   Limits the contact positions found in a line to the subsection of
    ///   the line covered by the line segment
    /// </summary>
    /// <param name="contacts">Contacts that will be limited to the line segment</param>
    private static void limitContactToRay(ref LineContacts contacts) {
      if(!float.IsNaN(contacts.EntryTime)) {
        bool contactLiesOutsideOfRay =
          (contacts.ExitTime < 0.0f);

        if(contactLiesOutsideOfRay) {
          contacts.EntryTime = float.NaN;
          contacts.ExitTime = float.NaN;
        } else {
          if(contacts.EntryTime < 0.0f) {
            contacts.EntryTime = 0.0f;
          }
        }
      }
    }