Exemple #1
0
        public void ClosestPointOnTriangleCorner2()
        {
            float   s;
            float   t;
            bool    inside;
            Vector3 closest = TrianglePathway.ClosestPointOnTriangle(ref _triangle, new Vector3(2f, 0, 0f), out s, out t, out inside);

            Assert.IsFalse(inside);
            Assert.AreEqual(1.0f, closest.X, float.Epsilon);
            Assert.AreEqual(0.0f, closest.Y, float.Epsilon);
            Assert.AreEqual(0.0f, closest.Z, float.Epsilon);
            Assert.AreEqual(0.0f, s, float.Epsilon);
            Assert.AreEqual(1.0f, t, float.Epsilon);
        }
Exemple #2
0
        public void ClosestPointInTriangleEdge2()
        {
            float   s;
            float   t;
            bool    inside;
            Vector3 closest = TrianglePathway.ClosestPointOnTriangle(ref _triangle, new Vector3(0.5f, 0, 0.1f), out s, out t, out inside);

            Assert.IsTrue(inside);
            Assert.AreEqual(0.5f, closest.X, float.Epsilon);
            Assert.AreEqual(0.0f, closest.Y, float.Epsilon);
            Assert.AreEqual(0.1f, closest.Z, float.Epsilon);
            Assert.AreEqual(0.1f, s, float.Epsilon);
            Assert.AreEqual(0.5f, t, float.Epsilon);
        }
Exemple #3
0
        private void GeneratePath()
        {
            var rand = new Random();

            float xOffsetDeriv = 0;
            float xOffset      = 0;

            var points = new List <Vector3>();

            for (var i = 0; i < 200; i++)
            {
                xOffsetDeriv = MathHelper.Clamp((float)rand.NextDouble() * 2 - (xOffsetDeriv * 0.0125f), -15, 15);
                xOffset     += xOffsetDeriv;

                points.Add(new Vector3(xOffset + 1, 0, i) * 5);
                points.Add(new Vector3(xOffset - 1, 0, i) * 5);
            }

            _path = new TrianglePathway(Enumerable.Range(0, points.Count - 2).Select(i => new TrianglePathway.Triangle(points[i], points[i + 1], points[i + 2])));
        }