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);
    }
示例#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());
        }
示例#4
0
文件: Segment3.cs 项目: 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 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));
    }
示例#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);
        }
示例#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);
        }
示例#8
0
文件: Ray3.cs 项目: 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);
        }
示例#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));
        }
示例#10
0
文件: Ray3.cs 项目: 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);
        }
示例#11
0
文件: Segment3.cs 项目: 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(
                Start, End - Start, plane.Offset, plane.Normal
                );

            limitContactToLineSegment(ref contacts);

            return(contacts);
        }
示例#12
0
文件: Segment3.cs 项目: 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(
                Start, End - Start, triangle.A, triangle.B, triangle.C
                );

            limitContactToLineSegment(ref contacts);

            return(contacts);
        }
示例#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));
        }
示例#14
0
文件: Ray3.cs 项目: 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;
                    }
                }
            }
        }
示例#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;
          }
        }
      }
    }
示例#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());
    }
示例#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;
          }
        }
      }
    }