Beispiel #1
0
        public void ClosestPoint_PerpendicularLines_DifferentOrigins()
        {
            var a = new Ray3(new Vector3(0, 1, -3), Vector3.UnitZ);
            var b = new Ray3(new Vector3(0, -1, 0), Vector3.UnitX);

            a.ClosestPoint(b, out var r1, out var r2);
            Assert.AreEqual(3, r1);
            Assert.AreEqual(0, r2);
        }
Beispiel #2
0
        public void AssertThat_RayClosestPoint_IsOnLine_AfterOneLength()
        {
            var ray   = new Ray3(new Vector3(0, 1, 0), new Vector3(0, 10, 0));
            var point = new Vector3(5, 150, 5);

            var closest = ray.ClosestPoint(point);

            Assert.AreEqual(new Vector3(0, 150, 0), closest);
        }
Beispiel #3
0
        public void ClosestPoint_AntiParallelLines()
        {
            var a = new Ray3(new Vector3(1, 2, 3), Vector3.UnitY);
            var b = new Ray3(new Vector3(1, 2, 3), -Vector3.UnitY);

            a.ClosestPoint(b, out var r1, out var r2);
            Assert.AreEqual(0, r1);
            Assert.AreEqual(0, r2);
        }
Beispiel #4
0
        public void AssertThat_RayClosestPoint_IsOnLine_BeforeStart()
        {
            var ray   = new Ray3(new Vector3(0, 1, 0), new Vector3(0, 10, 0));
            var point = new Vector3(5, 0, 5);

            var closest = ray.ClosestPoint(point);

            Assert.AreEqual(new Vector3(0, 0, 0), closest);
        }