Ejemplo n.º 1
0
        /// <summary>
        /// Run tests for Math.Net
        /// </summary>
        /// <seealso cref="http://www.mathdotnet.com/"/>
        /// <param name="results">The collection of results to add to</param>
        /// <remarks>Included using Nuget</remarks>
        private static void RunMathNetTests(Dictionary <string, long> results)
        {
            var libraryName = "MathNet";

            var a = new MathNet.Numerics.LinearAlgebra.Double.DenseVector(new double[] { 2, 4, 6 });
            var b = new MathNet.Numerics.LinearAlgebra.Double.DenseVector(new double[] { 5, 7, 10 });

            results.Add(
                "Cross Product => " + libraryName,
                Measure(
                    iterations,
                    () =>
            {
                var result = a.OuterProduct(b);             // Not sure if this is cross product or not
            }));

            results.Add(
                "Dot Product => " + libraryName,
                Measure(
                    iterations,
                    () =>
            {
                var result = a.DotProduct(b);
            }));

            results.Add(
                "Normalize => " + libraryName,
                Measure(
                    iterations,
                    () =>
            {
                var result = a.Normalize(0);
            }));

            results.Add(
                "Add => " + libraryName,
                Measure(
                    iterations,
                    () =>
            {
                var result = a + b;
            }));

            results.Add(
                "Subtract => " + libraryName,
                Measure(
                    iterations,
                    () =>
            {
                var result = a - b;
            }));
        }
Ejemplo n.º 2
0
Archivo: Grid.cs Proyecto: sin-us/sdhk
        private void AddCorner(int id, int t1, int t2, int t3)
        {
            TCorner c = Corners[id];

            TTile[] t = new[] { Tiles[t1], Tiles[t2], Tiles[t3] };
            VectorD v = t[0].TileCenterPosition + t[1].TileCenterPosition + t[2].TileCenterPosition;


            c.V = (VectorD)v.Normalize(2.0);
            for (int i = 0; i < 3; i++)
            {
                t[i].Corners[t[i].GetTilePosition(t[(i + 2) % 3])] = c;
                c.Tiles[i] = t[i];
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns unityvector holding the direction
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <returns></returns>
 public static XYPoint GetDirection(IXYPoint p1, IXYPoint p2)
 {
   MathNet.Numerics.LinearAlgebra.Double.DenseVector v = new MathNet.Numerics.LinearAlgebra.Double.DenseVector(2);
   v[0] = p2.X - p1.X;
   v[1] = p2.Y - p1.Y;
   v.Normalize(1);
   return new XYPoint(v[0], v[1]);
 }