Exemplo n.º 1
0
        public void TestMethodSum()
        {
            Arithmetics a = new Arithmetics();

            //a test composed out of two subtests

            Assert.AreEqual(23.5, a.Sum(13.5, 10));

            Assert.AreEqual(23, a.Sum(13, 10));
        }
Exemplo n.º 2
0
        public void TestAgainMethodSum()
        {
            Arithmetics a = new Arithmetics();


            Assert.AreEqual(15, a.Sum(new int[] { 1, 2, 3, 4, 5 }));
        }
Exemplo n.º 3
0
        } // End function CrossP

        /// <summary>
        /// Returns the DotProduct.
        /// </summary>
        /// <returns>T containing the value of the DotProduct.</returns>
        public static T DotP(MyVector3D <T> a, MyVector3D <T> b)
        {
            T s1 = Arithmetics <T> .Multiply(a.X, b.X);

            T s2 = Arithmetics <T> .Multiply(a.Y, b.Y);

            T s3 = Arithmetics <T> .Multiply(a.Z, b.Z);

            //A * B = ax*bx+ay*by+az*bz
            T retValue = Arithmetics <T> .Sum(s1, s2, s3);

            return(retValue);
        } // End function DotP
Exemplo n.º 4
0
        } // End function DotP

        public static T Angle_Rad(MyVector2D <T> a, MyVector2D <T> b)
        {
            T axbx = Arithmetics <T> .Multiply(a.X, b.X);

            T ayby = Arithmetics <T> .Multiply(a.Y, b.Y);

            T azbz = Arithmetics <T> .ZERO;

            T sumAB = Arithmetics <T> .Sum(axbx, ayby, azbz);

            T ax2 = Arithmetics <T> .Pow(a.X, 2);

            T ay2 = Arithmetics <T> .Pow(a.Y, 2);

            T az2 = Arithmetics <T> .ZERO;

            T bx2 = Arithmetics <T> .Pow(b.X, 2);

            T by2 = Arithmetics <T> .Pow(b.Y, 2);

            T bz2 = Arithmetics <T> .ZERO;


            T aSquare = Arithmetics <T> .Sum(ax2, ay2, az2);

            T bSquare = Arithmetics <T> .Sum(bx2, by2, bz2);

            T val = Arithmetics <T> .Divide(sumAB,
                                            (
                                                Arithmetics <T> .Multiply(Arithmetics <T> .Sqrt(aSquare), Arithmetics <T> .Sqrt(bSquare))
                                            )
                                            );

            T nReturnValue = Arithmetics <T> .Acos(val);

            return(nReturnValue);
        }  // End function Angle_Rad