コード例 #1
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);
    }
コード例 #2
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);
    }
コード例 #3
0
ファイル: LineContacts.Test.cs プロジェクト: minskowl/MY
        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;
                    }
                }
            }
        }
コード例 #5
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));
    }
コード例 #6
0
ファイル: LineContacts.Test.cs プロジェクト: minskowl/MY
        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
ファイル: LineContacts.Test.cs プロジェクト: minskowl/MY
        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
ファイル: LineContacts.Test.cs プロジェクト: minskowl/MY
        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
ファイル: Segment3.cs プロジェクト: pr0gramm3r1/AngryTanks
    /// <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
ファイル: Ray3.cs プロジェクト: pr0gramm3r1/AngryTanks
    /// <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;
          }
        }
      }
    }