Accord.Tests.Math.SimpleShapeCheckerTest.SimpleShapeCheckerTest C# (CSharp) Method

SimpleShapeCheckerTest() public method

public SimpleShapeCheckerTest ( ) : System
return System
        public SimpleShapeCheckerTest( )
        {
            System.Random rand = new System.Random( );

            // generate sample circles
            double radius = 100;

            for ( int i = 0; i < 360; i += 10 )
            {
                double angle = (double) i / 180 * System.Math.PI;

                // add point to ideal circle
                idealCicle.Add( new IntPoint(
                    (int) ( radius * System.Math.Cos( angle ) ),
                    (int) ( radius * System.Math.Sin( angle ) ) ) );

                // add a bit distortion for distorred cirlce
                double distorredRadius = radius + rand.Next( 7 ) - 3;

                distorredCircle.Add( new IntPoint(
                    (int) ( distorredRadius * System.Math.Cos( angle ) ),
                    (int) ( distorredRadius * System.Math.Sin( angle ) ) ) );
            }

            // generate sample squares
            square1.Add( new IntPoint( 0, 0 ) );
            square1.Add( new IntPoint( 50, 0 ) );
            square1.Add( new IntPoint( 100, 0 ) );
            square1.Add( new IntPoint( 100, 50 ) );
            square1.Add( new IntPoint( 100, 100 ) );
            square1.Add( new IntPoint( 50, 100 ) );
            square1.Add( new IntPoint( 0, 100 ) );
            square1.Add( new IntPoint( 0, 50 ) );

            square2.Add( new IntPoint( 50, 0 ) );
            square2.Add( new IntPoint( 75, 25 ) );
            square2.Add( new IntPoint( 100, 50 ) );
            square2.Add( new IntPoint( 75, 75 ) );
            square2.Add( new IntPoint( 50, 100 ) );
            square2.Add( new IntPoint( 25, 75 ) );
            square2.Add( new IntPoint( 0, 50 ) );
            square2.Add( new IntPoint( 25, 25 ) );

            // these should be obtained as corners
            square1Test.Add( new IntPoint( 0, 0 ) );
            square1Test.Add( new IntPoint( 100, 0 ) );
            square1Test.Add( new IntPoint( 100, 100 ) );
            square1Test.Add( new IntPoint( 0, 100 ) );

            square2Test.Add( new IntPoint( 50, 0 ) );
            square2Test.Add( new IntPoint( 100, 50 ) );
            square2Test.Add( new IntPoint( 50, 100 ) );
            square2Test.Add( new IntPoint( 0, 50 ) );

            // special square, which may look like circle, but should be recognized as circle
            square3.Add( new IntPoint( 50, 0 ) );
            square3.Add( new IntPoint( 100, 50 ) );
            square3.Add( new IntPoint( 50, 100 ) );
            square3.Add( new IntPoint( 0, 50 ) );

            // generate sample rectangle
            rectangle.Add( new IntPoint( 0, 0 ) );
            rectangle.Add( new IntPoint( 50, 0 ) );
            rectangle.Add( new IntPoint( 100, 0 ) );
            rectangle.Add( new IntPoint( 100, 20 ) );
            rectangle.Add( new IntPoint( 100, 40 ) );
            rectangle.Add( new IntPoint( 50, 40 ) );
            rectangle.Add( new IntPoint( 0, 40 ) );
            rectangle.Add( new IntPoint( 0, 20 ) );

            // generate some triangles
            triangle1.Add( new IntPoint( 0, 0 ) );
            triangle1.Add( new IntPoint( 50, 10 ) );
            triangle1.Add( new IntPoint( 100, 20 ) );
            triangle1.Add( new IntPoint( 90, 50 ) );
            triangle1.Add( new IntPoint( 80, 80 ) );
            triangle1.Add( new IntPoint( 40, 40 ) );

            isoscelesTriangle.Add( new IntPoint( 0, 0 ) );
            isoscelesTriangle.Add( new IntPoint( 50, 0 ) );
            isoscelesTriangle.Add( new IntPoint( 100, 0 ) );
            isoscelesTriangle.Add( new IntPoint( 75, 20 ) );
            isoscelesTriangle.Add( new IntPoint( 50, 40 ) );
            isoscelesTriangle.Add( new IntPoint( 25, 20 ) );

            equilateralTriangle.Add( new IntPoint( 0, 0 ) );
            equilateralTriangle.Add( new IntPoint( 50, 0 ) );
            equilateralTriangle.Add( new IntPoint( 100, 0 ) );
            equilateralTriangle.Add( new IntPoint( 75, 43 ) );
            equilateralTriangle.Add( new IntPoint( 50, 86 ) );
            equilateralTriangle.Add( new IntPoint( 25, 43 ) );

            rectangledTriangle.Add( new IntPoint( 0, 0 ) );
            rectangledTriangle.Add( new IntPoint( 20, 0 ) );
            rectangledTriangle.Add( new IntPoint( 40, 0 ) );
            rectangledTriangle.Add( new IntPoint( 20, 50 ) );
            rectangledTriangle.Add( new IntPoint( 0, 100 ) );
            rectangledTriangle.Add( new IntPoint( 0, 50 ) );
        }