Example #1
0
        /// <summary>
        /// Initialize Transformation and Invert Matrices for transforming
        /// points from frame to Foosbot World and Back
        /// </summary>
        /// <param name="frameWidth">Frame width</param>
        /// <param name="frameHeight">Frame height</param>
        /// <param name="worldWidth">Foosbot world width</param>
        /// <param name="worldHeight">Foosbot world height</param>
        private void InitializeTransformation(float frameWidth, float frameHeight, float worldWidth, float worldHeight)
        {
            //Create corners of frame
            System.Drawing.PointF[] originalPoints = new System.Drawing.PointF[4];
            originalPoints[0] = new System.Drawing.PointF(0, 0);
            originalPoints[1] = new System.Drawing.PointF(frameWidth, 0);
            originalPoints[2] = new System.Drawing.PointF(0, frameHeight);
            originalPoints[3] = new System.Drawing.PointF(frameWidth, frameHeight);

            //Create corners of foosbot world
            System.Drawing.PointF[] transformedPoints = new System.Drawing.PointF[4];
            transformedPoints[0] = new System.Drawing.PointF(0, 0);
            transformedPoints[1] = new System.Drawing.PointF(worldWidth, 0);
            transformedPoints[2] = new System.Drawing.PointF(0, worldHeight);
            transformedPoints[3] = new System.Drawing.PointF(worldWidth, worldHeight);

            //Calculate trabsformation matrix and store in static class
            Transformation.CalculateAndSetHomographyMatrix(originalPoints, transformedPoints);
        }