Beispiel #1
0
        /// <summary>
        /// Create a voxel of type T.
        /// </summary>
        /// <param name="X">The X-coordinate.</param>
        /// <param name="Y">The Y-coordinate.</param>
        /// <param name="Z">The Z-coordinate.</param>
        public Voxel(T X, T Y, T Z)
        {
            #region Initial Checks

            if (X == null)
            {
                throw new ArgumentNullException("The given x-coordinate must not be null!");
            }

            if (Y == null)
            {
                throw new ArgumentNullException("The given y-coordinate must not be null!");
            }

            if (Z == null)
            {
                throw new ArgumentNullException("The given z-coordinate must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;
            this.X    = X;
            this.Y    = Y;
            this.Z    = Z;
        }
Beispiel #2
0
        /// <summary>
        /// Create a rectangle of type T.
        /// </summary>
        /// <param name="Pixel">A pixel of type T in the upper left corner of the rectangle.</param>
        /// <param name="Width">The width of the rectangle.</param>
        /// <param name="Height">The height of the rectangle.</param>
        public Rectangle(IPixel <T> Pixel, T Width, T Height)
        {
            #region Initial Checks

            if (Pixel == null)
            {
                throw new ArgumentNullException("The given pixel must not be null!");
            }

            if (Width == null || Width.Equals(Math.Zero))
            {
                throw new ArgumentNullException("The given width must not be null or zero!");
            }

            if (Height == null || Height.Equals(Math.Zero))
            {
                throw new ArgumentNullException("The given height must not be null or zero!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.Left   = Pixel.X;
            this.Top    = Pixel.Y;
            this.Right  = Math.Add(Pixel.X, Width);
            this.Bottom = Math.Add(Pixel.Y, Height);

            this.Pixel1 = new Pixel <T>(Left, Top);
            this.Pixel2 = new Pixel <T>(Right, Bottom);

            this.Width    = Math.Distance(Left, Right);
            this.Height   = Math.Distance(Top, Bottom);
            this.Diameter = Pixel1.DistanceTo(Pixel2);
        }
Beispiel #3
0
        /// <summary>
        /// Create a 2-dimensional line of type T.
        /// </summary>
        /// <param name="Pixel1">A pixel of type T.</param>
        /// <param name="Pixel2">A pixel of type T.</param>
        public Line2D(IPixel <T> Pixel1, IPixel <T> Pixel2)
        {
            #region Initial Checks

            if (Pixel1 == null)
            {
                throw new ArgumentNullException("The given left-coordinate must not be null!");
            }

            if (Pixel2 == null)
            {
                throw new ArgumentNullException("The given right-coordinate must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X1 = Pixel1.X;
            this.Y1 = Pixel1.Y;
            this.X2 = Pixel2.X;
            this.Y2 = Pixel2.Y;

            this.Pixel1 = Pixel1;
            this.Pixel2 = Pixel2;

            this.Length = Pixel1.DistanceTo(Pixel2);
        }
Beispiel #4
0
        /// <summary>
        /// Create a 2-dimensional line of type T.
        /// </summary>
        /// <param name="Pixel">A pixel of type T.</param>
        /// <param name="X">The x-component.</param>
        /// <param name="Y">The y-component.</param>
        public Line2D(IPixel <T> Pixel, T X, T Y)
        {
            #region Initial Checks

            if (Pixel == null)
            {
                throw new ArgumentNullException("The given pixel must not be null!");
            }

            if (X == null)
            {
                throw new ArgumentNullException("The given x-component must not be null!");
            }

            if (Y == null)
            {
                throw new ArgumentNullException("The given y-component must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X1 = Pixel.X;
            this.Y1 = Pixel.Y;
            this.X2 = Math.Add(Pixel.X, X);
            this.Y2 = Math.Add(Pixel.Y, Y);

            this.Pixel1 = new Pixel <T>(X1, Y1);
            this.Pixel2 = new Pixel <T>(X2, Y2);

            this.Length = Pixel1.DistanceTo(Pixel2);
        }
Beispiel #5
0
        /// <summary>
        /// Create a 2-dimensional vector of type T.
        /// </summary>
        /// <param name="X1">The first x-coordinate of the vector.</param>
        /// <param name="Y1">The first y-coordinate of the vector.</param>
        /// <param name="X2">The second x-coordinate of the vector.</param>
        /// <param name="Y2">The second y-coordinate of the vector.</param>
        public Vector2D(T X1, T Y1, T X2, T Y2)
        {
            #region Initial Checks

            if (X1 == null)
            {
                throw new ArgumentNullException("The given left-coordinate must not be null!");
            }

            if (Y1 == null)
            {
                throw new ArgumentNullException("The given top-coordinate must not be null!");
            }

            if (X2 == null)
            {
                throw new ArgumentNullException("The given right-coordinate must not be null!");
            }

            if (Y2 == null)
            {
                throw new ArgumentNullException("The given bottom-coordinate must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X      = Math.Sub(X1, X2);
            this.Y      = Math.Sub(Y1, Y2);
            this.Length = new Pixel <T>(X1, Y1).DistanceTo(X2, Y2);
        }
Beispiel #6
0
        /// <summary>
        /// Create a circle of type T.
        /// </summary>
        /// <param name="Center">The center of the circle.</param>
        /// <param name="Radius">The radius of the circle.</param>
        public Circle(IPixel <T> Center, T Radius)
        {
            #region Initial Checks

            if (Center == null)
            {
                throw new ArgumentNullException("The given center pixel must not be null!");
            }

            if (Radius == null)
            {
                throw new ArgumentNullException("The given radius must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Radius.Equals(Math.Zero))
            {
                throw new ArgumentException("The given radius must not be zero!");
            }

            #endregion

            this.X      = Center.X;
            this.Y      = Center.Y;
            this.Center = Center;
            this.Radius = Radius;
        }
Beispiel #7
0
        /// <summary>
        /// Create a polygon of type T.
        /// </summary>
        /// <param name="Pixels">The pixels of the polygon.</param>
        public Polygon(params IPixel <T>[] Pixels)
        {
            #region Initial Checks

            if (Pixels == null || Pixels.Length <= 3)
            {
                throw new ArgumentNullException("The given array of pixels must not be null or smaller than three!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            //if (Pixel1.Equals(Pixel2) ||
            //    Pixel1.Equals(Pixel3) ||
            //    Pixel2.Equals(Pixel3))
            //    throw new ArgumentException("All distances between the pixels must be larger than zero!");

            //if (Pixel1.X.Equals(Pixel2.X) &&
            //    Pixel2.X.Equals(Pixel3.X))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            //if (Pixel1.Y.Equals(Pixel2.Y) &&
            //    Pixel2.Y.Equals(Pixel3.Y))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            #endregion

            this._Pixels = new List <IPixel <T> >(Pixels);
        }
Beispiel #8
0
        /// <summary>
        /// Create a 1-dimensional line of type T.
        /// </summary>
        /// <param name="Left">The left-coordinate of the line.</param>
        /// <param name="Right">The right-coordinate of the line.</param>
        public Line1D(T Left, T Right)
        {
            #region Initial Checks

            if (Left == null)
            {
                throw new ArgumentNullException("The given left-coordinate must not be null!");
            }

            if (Right == null)
            {
                throw new ArgumentNullException("The given right-coordinate must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Math.Distance(Left, Right).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting size must not be zero!");
            }

            #endregion

            this.Left  = Math.Min(Left, Right);
            this.Right = Math.Max(Left, Right);
        }
Beispiel #9
0
        /// <summary>
        /// Create a cube of type T.
        /// </summary>
        /// <param name="Voxel">A Voxel of type T in the upper left front corner of the cube.</param>
        /// <param name="Width">The width of the cube.</param>
        /// <param name="Height">The height of the cube.</param>
        /// <param name="Depth">The depth of the cube.</param>
        public Cube(Voxel <T> Voxel, T Width, T Height, T Depth)
        {
            #region Initial Checks

            if (Voxel == null)
            {
                throw new ArgumentNullException("The given voxel must not be null!");
            }

            if (Width == null)
            {
                throw new ArgumentNullException("The given width must not be null!");
            }

            if (Height == null)
            {
                throw new ArgumentNullException("The given height must not be null!");
            }

            if (Depth == null)
            {
                throw new ArgumentNullException("The given depth must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Math.Distance(Left, Right).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting width must not be zero!");
            }

            if (Math.Distance(Top, Bottom).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting height must not be zero!");
            }

            if (Math.Distance(Front, Behind).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting depth must not be zero!");
            }

            #endregion

            this.Left   = Voxel.X;
            this.Top    = Voxel.Y;
            this.Front  = Voxel.Z;
            this.Right  = Math.Add(Voxel.X, Width);
            this.Bottom = Math.Add(Voxel.Y, Height);
            this.Behind = Math.Add(Voxel.Z, Depth);
        }
Beispiel #10
0
 public void Set(IMaths maths, Neuron neuron, List <Neuron> inputNeurons)
 {
     foreach (var inputNeuron in inputNeurons)
     {
         var synapse = new Synapse()
         {
             FromNeuron = inputNeuron,
             ToNeuron   = neuron,
             Weight     = maths.Random()
         };
         inputNeuron.OutputSynapses.Add(synapse);
         neuron.InputSynapses.Add(synapse);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Create a rectangle of type T.
        /// </summary>
        /// <param name="Left">The left-coordinate of the rectangle.</param>
        /// <param name="Top">The top-coordinate of the rectangle.</param>
        /// <param name="Right">The right-coordinate of the rectangle.</param>
        /// <param name="Bottom">The bottom-coordinate of the rectangle.</param>
        public Rectangle(T Left, T Top, T Right, T Bottom)
        {
            #region Initial Checks

            if (Left == null)
            {
                throw new ArgumentNullException("The given left-coordinate must not be null!");
            }

            if (Top == null)
            {
                throw new ArgumentNullException("The given top-coordinate must not be null!");
            }

            if (Right == null)
            {
                throw new ArgumentNullException("The given right-coordinate must not be null!");
            }

            if (Bottom == null)
            {
                throw new ArgumentNullException("The given bottom-coordinate must not be null!");
            }

            if (Left.Equals(Right))
            {
                throw new ArgumentException("The width of the rectangle must not be zero!");
            }

            if (Top.Equals(Bottom))
            {
                throw new ArgumentException("The height of the rectangle must not be zero!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.Left   = Math.Min(Left, Right);
            this.Top    = Math.Min(Top, Bottom);
            this.Right  = Math.Max(Left, Right);
            this.Bottom = Math.Max(Top, Bottom);

            this.Pixel1 = new Pixel <T>(Left, Top);
            this.Pixel2 = new Pixel <T>(Right, Bottom);

            this.Width    = Math.Distance(Left, Right);
            this.Height   = Math.Distance(Top, Bottom);
            this.Diameter = Pixel1.DistanceTo(Pixel2);
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            IMaths maths = MathsFactory.CreateMaths();

            Console.WriteLine(maths.Addieren(1, 5));
            Console.WriteLine(maths.Subtrahieren(10, 9));

            IMathsExtended mathsExtended = MathsFactory.CreateMathsExtended();

            Console.WriteLine(mathsExtended.Dividieren(12, 3));
            Console.WriteLine(mathsExtended.Multiplizieren(9, 4));

            IMathsQuadrat mathsQuadrat = MathsFactory.CreateMathsQuadrat();

            mathsQuadrat.Quadrieren(5);
            Console.ReadKey();
        }
Beispiel #13
0
        /// <summary>
        /// Create a cube of type T.
        /// </summary>
        /// <param name="Voxel1">A Voxel of type T.</param>
        /// <param name="Voxel2">A Voxel of type T.</param>
        public Cube(Voxel <T> Voxel1, Voxel <T> Voxel2)
        {
            #region Initial Checks

            if (Voxel1 == null)
            {
                throw new ArgumentNullException("The given first voxel must not be null!");
            }

            if (Voxel2 == null)
            {
                throw new ArgumentNullException("The given second voxel must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Math.Distance(Left, Right).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting width must not be zero!");
            }

            if (Math.Distance(Top, Bottom).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting height must not be zero!");
            }

            if (Math.Distance(Front, Behind).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting depth must not be zero!");
            }

            #endregion

            this.Left   = Math.Min(Voxel1.X, Voxel2.X);
            this.Top    = Math.Min(Voxel1.Y, Voxel2.Y);
            this.Front  = Math.Min(Voxel1.Z, Voxel2.Z);
            this.Right  = Math.Max(Voxel1.X, Voxel2.X);
            this.Bottom = Math.Max(Voxel1.Y, Voxel2.Y);
            this.Behind = Math.Max(Voxel1.Z, Voxel2.Z);
        }
Beispiel #14
0
        /// <summary>
        /// Create a sphere of type T.
        /// </summary>
        /// <param name="Left">The left-coordinate of the sphere.</param>
        /// <param name="Top">The top-coordinate of the sphere.</param>
        /// <param name="Front">The front-coordinate of the sphere.</param>
        /// <param name="Radius">The radius parameter.</param>
        public Sphere(T Left, T Top, T Front, T Radius)
        {
            #region Initial Checks

            if (Left == null)
            {
                throw new ArgumentNullException("The given left-coordinate must not be null!");
            }

            if (Top == null)
            {
                throw new ArgumentNullException("The given top-coordinate must not be null!");
            }

            if (Front == null)
            {
                throw new ArgumentNullException("The given front-coordinate must not be null!");
            }

            if (Radius == null)
            {
                throw new ArgumentNullException("The given radius must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Radius.Equals(Math.Zero))
            {
                throw new ArgumentException("The given radius must not be zero!");
            }

            #endregion

            this.Left   = Left;
            this.Top    = Top;
            this.Center = new Voxel <T>(Left, Top, Front);
            this.Radius = Radius;
        }
Beispiel #15
0
        /// <summary>
        /// Create a rectangle of type T.
        /// </summary>
        /// <param name="Pixel1">The left/top pixel of the rectangle.</param>
        /// <param name="Pixel2">The right/bottom pixel of the rectangle.</param>
        public Rectangle(IPixel <T> Pixel1, IPixel <T> Pixel2)
        {
            #region Initial Checks

            if (Pixel1 == null)
            {
                throw new ArgumentNullException("The given first pixel must not be null!");
            }

            if (Pixel2 == null)
            {
                throw new ArgumentNullException("The given second pixel must not be null!");
            }

            if (Pixel1.X.Equals(Pixel2.X))
            {
                throw new ArgumentException("The width of the rectangle must not be zero!");
            }

            if (Pixel1.Y.Equals(Pixel2.Y))
            {
                throw new ArgumentException("The height of the rectangle must not be zero!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.Left   = Math.Min(Pixel1.X, Pixel2.X);
            this.Top    = Math.Min(Pixel1.Y, Pixel2.Y);
            this.Right  = Math.Max(Pixel1.X, Pixel2.X);
            this.Bottom = Math.Max(Pixel1.Y, Pixel2.Y);

            this.Pixel1 = new Pixel <T>(Left, Top);
            this.Pixel2 = new Pixel <T>(Right, Bottom);

            this.Width    = Math.Distance(Left, Right);
            this.Height   = Math.Distance(Top, Bottom);
            this.Diameter = Pixel1.DistanceTo(Pixel2);
        }
Beispiel #16
0
        /// <summary>
        /// Create a 2-dimensional vector of type T.
        /// </summary>
        /// <param name="Pixel1">A pixel of type T.</param>
        /// <param name="Pixel2">A pixel of type T.</param>
        public Vector2D(IPixel <T> Pixel1, IPixel <T> Pixel2)
        {
            #region Initial Checks

            if (Pixel1 == null)
            {
                throw new ArgumentNullException("The first pixel must not be null!");
            }

            if (Pixel2 == null)
            {
                throw new ArgumentNullException("The second pixel must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X      = Math.Sub(Pixel1.X, Pixel2.X);
            this.Y      = Math.Sub(Pixel1.Y, Pixel2.Y);
            this.Length = Pixel1.DistanceTo(Pixel2);
        }
Beispiel #17
0
        /// <summary>
        /// Create a 2-dimensional vector of type T.
        /// </summary>
        /// <param name="Vector1">A vector of type T.</param>
        /// <param name="Vector2">A vector of type T.</param>
        public Vector2D(IVector2D <T> Vector1, IVector2D <T> Vector2)
        {
            #region Initial Checks

            if (Vector1 == null)
            {
                throw new ArgumentNullException("The first vector must not be null!");
            }

            if (Vector2 == null)
            {
                throw new ArgumentNullException("The second vector must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X      = Math.Sub(Vector1.X, Vector2.X);
            this.Y      = Math.Sub(Vector1.Y, Vector2.Y);
            this.Length = Vector1.DistanceTo(Vector2);
        }
Beispiel #18
0
        /// <summary>
        /// Create a 2-dimensional vector of type T.
        /// </summary>
        /// <param name="X">The x-component of the vector.</param>
        /// <param name="Y">The y-component of the vector.</param>
        public Vector2D(T X, T Y)
        {
            #region Initial Checks

            if (X == null)
            {
                throw new ArgumentNullException("The given x-component must not be null!");
            }

            if (Y == null)
            {
                throw new ArgumentNullException("The given y-component must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X      = X;
            this.Y      = Y;
            this.Length = new Pixel <T>(Math.Zero, Math.Zero).DistanceTo(X, Y);
        }
Beispiel #19
0
        /// <summary>
        /// Create a 2-dimensional line of type T.
        /// </summary>
        /// <param name="X1">The first x-coordinate of the line.</param>
        /// <param name="Y1">The first y-coordinate of the line.</param>
        /// <param name="X2">The second x-coordinate of the line.</param>
        /// <param name="Y2">The second y-coordinate of the line.</param>
        public Line2D(T X1, T Y1, T X2, T Y2)
        {
            #region Initial Checks

            if (X1 == null)
            {
                throw new ArgumentNullException("The first x-coordinate must not be null!");
            }

            if (Y1 == null)
            {
                throw new ArgumentNullException("The first y-coordinate must not be null!");
            }

            if (X2 == null)
            {
                throw new ArgumentNullException("The second x-coordinate must not be null!");
            }

            if (Y2 == null)
            {
                throw new ArgumentNullException("The second y-coordinate must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X1 = X1;
            this.Y1 = Y1;
            this.X2 = X2;
            this.Y2 = Y2;

            this.Pixel1 = new Pixel <T>(X1, Y1);
            this.Pixel2 = new Pixel <T>(X2, Y2);

            this.Length = Pixel1.DistanceTo(Pixel2);
        }
Beispiel #20
0
        /// <summary>
        /// Create a circle of type T.
        /// </summary>
        /// <param name="X">The x-coordinate of the circle.</param>
        /// <param name="Y">The y-coordinate of the circle.</param>
        /// <param name="Radius">The radius of the circle.</param>
        public Circle(T X, T Y, T Radius)
        {
            #region Initial Checks

            if (X == null)
            {
                throw new ArgumentNullException("The given x-coordinate must not be null!");
            }

            if (Y == null)
            {
                throw new ArgumentNullException("The given y-coordinate must not be null!");
            }

            if (Radius == null)
            {
                throw new ArgumentNullException("The given radius must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Radius.Equals(Math.Zero))
            {
                throw new ArgumentException("The given radius must not be zero!");
            }

            #endregion

            this.X      = X;
            this.Y      = Y;
            this.Center = new Pixel <T>(X, Y);
            this.Radius = Radius;
        }
Beispiel #21
0
        /// <summary>
        /// Create a triangle of type T.
        /// </summary>
        /// <param name="Pixel1">The first pixel of the triangle.</param>
        /// <param name="Pixel2">The second pixel of the triangle.</param>
        /// <param name="Pixel3">The third pixel of the triangle.</param>
        public Triangle(IPixel <T> Pixel1, IPixel <T> Pixel2, IPixel <T> Pixel3)
        {
            #region Initial Checks

            if (Pixel1 == null)
            {
                throw new ArgumentNullException("The given first pixel must not be null!");
            }

            if (Pixel2 == null)
            {
                throw new ArgumentNullException("The given second pixel must not be null!");
            }

            if (Pixel3 == null)
            {
                throw new ArgumentNullException("The given third pixel must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Pixel1.Equals(Pixel2) ||
                Pixel1.Equals(Pixel3) ||
                Pixel2.Equals(Pixel3))
            {
                throw new ArgumentException("All distances between the pixels must be larger than zero!");
            }

            if (Pixel1.X.Equals(Pixel2.X) &&
                Pixel2.X.Equals(Pixel3.X))
            {
                throw new ArgumentException("All three pixels must not be on a single line!");
            }

            if (Pixel1.Y.Equals(Pixel2.Y) &&
                Pixel2.Y.Equals(Pixel3.Y))
            {
                throw new ArgumentException("All three pixels must not be on a single line!");
            }

            #endregion

            #region Sort Pixels

            // Sort by x-coordinate.
            while (true)
            {
                if (Pixel1.X.IsLargerThan(Pixel2.X))
                {
                    Pixel <T> .Swap(ref Pixel1, ref Pixel2);

                    continue;
                }

                if (Pixel1.X.IsLargerThan(Pixel3.X))
                {
                    Pixel <T> .Swap(ref Pixel1, ref Pixel3);

                    continue;
                }

                if (Pixel2.X.IsLargerThan(Pixel3.X))
                {
                    Pixel <T> .Swap(ref Pixel2, ref Pixel3);

                    continue;
                }

                break;
            }

            // Sort by y-coordinate if x-coordinates are the same
            if (Pixel1.X.Equals(Pixel2.X))
            {
                if (Pixel1.Y.IsLargerThan(Pixel2.Y))
                {
                    Pixel <T> .Swap(ref Pixel1, ref Pixel2);
                }
            }

            if (Pixel2.X.Equals(Pixel3.X))
            {
                if (Pixel2.Y.IsLargerThan(Pixel3.Y))
                {
                    Pixel <T> .Swap(ref Pixel1, ref Pixel2);
                }
            }

            #endregion

            this.P1 = Pixel1;
            this.P2 = Pixel2;
            this.P3 = Pixel3;
        }
Beispiel #22
0
 public TestableAudioSource(IAudioSource audio, IMaths maths)
 {
     this.audio = audio;
     this.maths = maths;
 }
Beispiel #23
0
        /// <summary>
        /// Create a cube of type T.
        /// </summary>
        /// <param name="Left">The left parameter.</param>
        /// <param name="Top">The top parameter.</param>
        /// <param name="Front">The front parameter.</param>
        /// <param name="Right">The right parameter.</param>
        /// <param name="Bottom">The bottom parameter.</param>
        /// <param name="Behind">The behind parameter.</param>
        public Cube(T Left, T Top, T Front, T Right, T Bottom, T Behind)
        {
            #region Initial Checks

            if (Left == null)
            {
                throw new ArgumentNullException("The given left coordinate must not be null!");
            }

            if (Top == null)
            {
                throw new ArgumentNullException("The given top coordinate must not be null!");
            }

            if (Front == null)
            {
                throw new ArgumentNullException("The given front coordinate must not be null!");
            }

            if (Right == null)
            {
                throw new ArgumentNullException("The given right coordinate must not be null!");
            }

            if (Bottom == null)
            {
                throw new ArgumentNullException("The given bottom coordinate must not be null!");
            }

            if (Behind == null)
            {
                throw new ArgumentNullException("The given behind coordinate must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Math.Distance(Left, Right).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting width must not be zero!");
            }

            if (Math.Distance(Top, Bottom).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting height must not be zero!");
            }

            if (Math.Distance(Front, Behind).Equals(Math.Zero))
            {
                throw new ArgumentException("The resulting depth must not be zero!");
            }

            #endregion

            this.Left   = Math.Min(Left, Right);
            this.Top    = Math.Min(Top, Bottom);
            this.Front  = Math.Min(Front, Behind);
            this.Right  = Math.Max(Left, Right);
            this.Bottom = Math.Max(Top, Bottom);
            this.Behind = Math.Max(Front, Behind);
        }
Beispiel #24
0
        /// <summary>
        /// Creates a circumcircle of type T based on three pixels.
        /// </summary>
        /// <param name="Pixel1">The first pixel of the triangle.</param>
        /// <param name="Pixel2">The second pixel of the triangle.</param>
        /// <param name="Pixel3">The third pixel of the triangle.</param>
        public Circle(IPixel <T> Pixel1, IPixel <T> Pixel2, IPixel <T> Pixel3)
        {
            #region Initial Checks

            if (Pixel1 == null)
            {
                throw new ArgumentNullException("The given first pixel must not be null!");
            }

            if (Pixel2 == null)
            {
                throw new ArgumentNullException("The given second pixel must not be null!");
            }

            if (Pixel3 == null)
            {
                throw new ArgumentNullException("The given third pixel must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            #region Math Checks

            if (Pixel1.Equals(Pixel2) ||
                Pixel1.Equals(Pixel3) ||
                Pixel2.Equals(Pixel3))
            {
                throw new ArgumentException("All distances between the pixels must be larger than zero!");
            }

            //if (Pixel1.X.Equals(Pixel2.X) &&
            //    Pixel2.X.Equals(Pixel3.X))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            //if (Pixel1.Y.Equals(Pixel2.Y) &&
            //    Pixel2.Y.Equals(Pixel3.Y))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            #endregion

            var _Line12 = new Line2D <T>(Pixel1, Pixel2);
            var _Line23 = new Line2D <T>(Pixel2, Pixel3);

            var _Normale12 = _Line12.Normale;
            var _Normale23 = _Line23.Normale;

            Center = new Line2D <T>(_Line12.Center, _Normale12.X, _Normale12.Y).
                     Intersection(
                new Line2D <T>(_Line23.Center, _Normale23.X, _Normale23.Y));

            if (Center != null)
            {
                X      = Center.X;
                Y      = Center.Y;
                Radius = Pixel1.DistanceTo(X, Y);
            }
            else
            {
                X      = default(T);
                Y      = default(T);
                Radius = default(T);
            }
        }
Beispiel #25
0
 public CompoundInterest(IMaths maths)
 {
     _IMaths = maths;
 }
Beispiel #26
0
 public SimpleInterest(IMaths maths)
 {
     _IMaths = maths;
 }
Beispiel #27
0
 public ValuesController(IMaths maths)
 {
     this.maths = maths;
 }
Beispiel #28
0
 public TestableAudioSource(IAudioSource audio, IMaths maths) {
     this.audio = audio;
     this.maths = maths;
 }
 public Simpleinterest(IMaths maths)
 {
     Maths = maths;
 }