예제 #1
0
        public void TimeForMultipleCollisionPoints_Test()
        {
            var origin      = new Vector3(0, 0, 0);
            var microphones = new List <MicrophoneSphere>()
            {
                new MicrophoneSphere(new Vector3(1, 5, 3), 0.5f)
            };

            var firstRay = new AcousticRay(origin, microphones[0].Center);

            var firstRayVectors = new List <Vector3>()
            {
                new Vector3(1, 2, 3),
                new Vector3(1, 2, 4),
                new Vector3(1, 3, 3),
                new Vector3(1, 5.02f, 3)
            };

            foreach (var vec in firstRayVectors)
            {
                firstRay.CollisionPoints.Add(vec);
            }

            var rays = new List <AcousticRay>
            {
                firstRay
            };

            var raysDictionary = new Dictionary <int, List <AcousticRay> >();

            raysDictionary[microphones[0].Id] = rays;

            var distanceCalculator = new DistanceCalculator(raysDictionary, microphones);

            distanceCalculator.ComputeDistances();

            var times = TimeCalculator.GetTime(raysDictionary, microphones);

            Assert.IsTrue(Math.Abs(times[microphones[0].Id][0] - 0.0238) < 1e-3);
        }