Exemplo n.º 1
0
        public void GetLength()
        {
            HermiteSegment3F s = new HermiteSegment3F
              {
            Point1 = new Vector3F(1, 2, 3),
            Tangent1 = (new Vector3F(10, 3, 6) - new Vector3F(1, 2, 3)) * 3,
            Tangent2 = (new Vector3F(10, 2, 12) - new Vector3F(7, 8, 19)) * 3,
            Point2 = new Vector3F(10, 2, 12),
              };

              BezierSegment3F b = new BezierSegment3F
              {
            Point1 = new Vector3F(1, 2, 3),
            ControlPoint1 = new Vector3F(10, 3, 6),
            ControlPoint2 = new Vector3F(7, 8, 19),
            Point2 = new Vector3F(10, 2, 12),
              };

              float length1 = s.GetLength(0, 1, 20, Numeric.EpsilonF);
              float length2 = b.GetLength(0, 1, 20, Numeric.EpsilonF);
              Assert.IsTrue(Numeric.AreEqual(length1, length2));

              float approxLength = 0;
              const float step = 0.0001f;
              for (float u = 0; u <= 1.0f; u += step)
            approxLength += (s.GetPoint(u) - s.GetPoint(u + step)).Length;

              Assert.IsTrue(Numeric.AreEqual(approxLength, length1, 0.01f));
              Assert.IsTrue(Numeric.AreEqual(s.GetLength(0, 1, 100, Numeric.EpsilonF), s.GetLength(0, 0.5f, 100, Numeric.EpsilonF) + s.GetLength(0.5f, 1, 100, Numeric.EpsilonF)));
              Assert.IsTrue(Numeric.AreEqual(s.GetLength(0, 1, 100, Numeric.EpsilonF), s.GetLength(1, 0, 100, Numeric.EpsilonF)));
        }
Exemplo n.º 2
0
        public void GetLength()
        {
            HermiteSegment3F s = new HermiteSegment3F
            {
                Point1   = new Vector3F(1, 2, 3),
                Tangent1 = (new Vector3F(10, 3, 6) - new Vector3F(1, 2, 3)) * 3,
                Tangent2 = (new Vector3F(10, 2, 12) - new Vector3F(7, 8, 19)) * 3,
                Point2   = new Vector3F(10, 2, 12),
            };

            BezierSegment3F b = new BezierSegment3F
            {
                Point1        = new Vector3F(1, 2, 3),
                ControlPoint1 = new Vector3F(10, 3, 6),
                ControlPoint2 = new Vector3F(7, 8, 19),
                Point2        = new Vector3F(10, 2, 12),
            };

            float length1 = s.GetLength(0, 1, 20, Numeric.EpsilonF);
            float length2 = b.GetLength(0, 1, 20, Numeric.EpsilonF);

            Assert.IsTrue(Numeric.AreEqual(length1, length2));

            float       approxLength = 0;
            const float step         = 0.0001f;

            for (float u = 0; u <= 1.0f; u += step)
            {
                approxLength += (s.GetPoint(u) - s.GetPoint(u + step)).Length;
            }

            Assert.IsTrue(Numeric.AreEqual(approxLength, length1, 0.01f));
            Assert.IsTrue(Numeric.AreEqual(s.GetLength(0, 1, 100, Numeric.EpsilonF), s.GetLength(0, 0.5f, 100, Numeric.EpsilonF) + s.GetLength(0.5f, 1, 100, Numeric.EpsilonF)));
            Assert.IsTrue(Numeric.AreEqual(s.GetLength(0, 1, 100, Numeric.EpsilonF), s.GetLength(1, 0, 100, Numeric.EpsilonF)));
        }
Exemplo n.º 3
0
        public void GetPoint()
        {
            HermiteSegment3F s = new HermiteSegment3F
            {
                Point1   = new Vector3F(1, 2, 3),
                Tangent1 = (new Vector3F(10, 3, 6) - new Vector3F(1, 2, 3)) * 3,
                Tangent2 = (new Vector3F(10, 2, 12) - new Vector3F(7, 8, 19)) * 3,
                Point2   = new Vector3F(10, 2, 12),
            };

            BezierSegment3F b = new BezierSegment3F
            {
                Point1        = new Vector3F(1, 2, 3),
                ControlPoint1 = new Vector3F(10, 3, 6),
                ControlPoint2 = new Vector3F(7, 8, 19),
                Point2        = new Vector3F(10, 2, 12),
            };

            Assert.IsTrue(Vector3F.AreNumericallyEqual(s.Point1, s.GetPoint(0)));
            Assert.IsTrue(Vector3F.AreNumericallyEqual(s.Point2, s.GetPoint(1)));
            Assert.IsTrue(Vector3F.AreNumericallyEqual(b.GetPoint(0.33f), s.GetPoint(0.33f)));
        }
Exemplo n.º 4
0
        public void GetPoint()
        {
            HermiteSegment3F s = new HermiteSegment3F
              {
            Point1 = new Vector3F(1, 2, 3),
            Tangent1 = (new Vector3F(10, 3, 6) - new Vector3F(1, 2, 3)) * 3,
            Tangent2 = (new Vector3F(10, 2, 12) - new Vector3F(7, 8, 19)) * 3,
            Point2 = new Vector3F(10, 2, 12),
              };

              BezierSegment3F b = new BezierSegment3F
              {
            Point1 = new Vector3F(1, 2, 3),
            ControlPoint1 = new Vector3F(10, 3, 6),
            ControlPoint2 = new Vector3F(7, 8, 19),
            Point2 = new Vector3F(10, 2, 12),
              };

              Assert.IsTrue(Vector3F.AreNumericallyEqual(s.Point1, s.GetPoint(0)));
              Assert.IsTrue(Vector3F.AreNumericallyEqual(s.Point2, s.GetPoint(1)));
              Assert.IsTrue(Vector3F.AreNumericallyEqual(b.GetPoint(0.33f), s.GetPoint(0.33f)));
        }
        public void GetPoint()
        {
            CatmullRomSegment3F c = new CatmullRomSegment3F
            {
                Point1 = new Vector3(1, 2, 3),
                Point2 = new Vector3(10, 3, 6),
                Point3 = new Vector3(7, 8, 19),
                Point4 = new Vector3(10, 2, 12),
            };

            HermiteSegment3F h = new HermiteSegment3F
            {
                Point1   = c.Point2,
                Tangent1 = (c.Point3 - c.Point1) * 0.5f,
                Tangent2 = (c.Point4 - c.Point2) * 0.5f,
                Point2   = c.Point3,
            };

            Assert.IsTrue(Vector3.AreNumericallyEqual(c.Point2, c.GetPoint(0)));
            Assert.IsTrue(Vector3.AreNumericallyEqual(c.Point3, c.GetPoint(1)));
            Assert.IsTrue(Vector3.AreNumericallyEqual(h.GetPoint(0.33f), c.GetPoint(0.33f)));
        }
Exemplo n.º 6
0
        public void GetPoint()
        {
            CardinalSegment3F c = new CardinalSegment3F
            {
                Point1  = new Vector3F(1, 2, 3),
                Point2  = new Vector3F(10, 3, 6),
                Point3  = new Vector3F(7, 8, 19),
                Point4  = new Vector3F(10, 2, 12),
                Tension = 0.3f
            };

            HermiteSegment3F h = new HermiteSegment3F
            {
                Point1   = c.Point2,
                Tangent1 = (1 - c.Tension) * (c.Point3 - c.Point1) * 0.5f,
                Tangent2 = (1 - c.Tension) * (c.Point4 - c.Point2) * 0.5f,
                Point2   = c.Point3,
            };

            Assert.IsTrue(Vector3F.AreNumericallyEqual(c.Point2, c.GetPoint(0)));
            Assert.IsTrue(Vector3F.AreNumericallyEqual(c.Point3, c.GetPoint(1)));
            Assert.IsTrue(Vector3F.AreNumericallyEqual(h.GetPoint(0.33f), c.GetPoint(0.33f)));
        }
Exemplo n.º 7
0
        public void GetPoint()
        {
            CatmullRomSegment3F c = new CatmullRomSegment3F
              {
            Point1 = new Vector3F(1, 2, 3),
            Point2 = new Vector3F(10, 3, 6),
            Point3 = new Vector3F(7, 8, 19),
            Point4 = new Vector3F(10, 2, 12),
              };

              HermiteSegment3F h = new HermiteSegment3F
              {
            Point1 = c.Point2,
            Tangent1 = (c.Point3 - c.Point1) * 0.5f,
            Tangent2 = (c.Point4 - c.Point2) * 0.5f,
            Point2 = c.Point3,
              };

              Assert.IsTrue(Vector3F.AreNumericallyEqual(c.Point2, c.GetPoint(0)));
              Assert.IsTrue(Vector3F.AreNumericallyEqual(c.Point3, c.GetPoint(1)));
              Assert.IsTrue(Vector3F.AreNumericallyEqual(h.GetPoint(0.33f), c.GetPoint(0.33f)));
        }