public static AreaPoint CalculateAreaPoint(RealWorldPoint realWorldPoint)
 {
     var areaPoint = new AreaPoint();
     var areaVector = ChangeOfBasis.GetVectorInNewBasis(realWorldPoint.ToVector3D());
     areaPoint.X = (int) areaVector.X;
     areaPoint.Y = (int) areaVector.Y;
     return areaPoint;
 }
        public BeamerPoint CalculateBeamerCoordinate(AreaPoint areaCoordinate)
        {
            var width = Beamer.GetBeamerWidth();
            var height = Beamer.GetBeamerHeight();

            var px = areaCoordinate.X * (width - 2 * CalibrationImage.TILE_WIDTH) / width;
            var py = (areaCoordinate.Y) * (height - 2 * CalibrationImage.TILE_HEIGHT) / height;

            return new BeamerPoint { X = px, Y = py };
        }
        public void CalculateObstacleCentroid()
        {
            var obstacleImage = kinect.GetColorImage();
            var diffImage = kinect.GetDifferenceImage(obstacleImage, blankImage, KinectBeamerCalibration.THRESHOLD);

            var initPoints = new List<Vector2D>() { new Vector2D { X = 0, Y = 0 } };
            var centroids = KMeans.DoKMeans(KinectPointArrayHelper.ExtractBlackPointsAs2dVector(diffImage), initPoints);

            var kinectPointCentroids = new List<KinectPoint>();
            kinectPointCentroids.Add(kinectPoints[(int)centroids[0].X, (int)centroids[0].Y]);

            ConvertKinectToRealWorld(new CalculateToRealWorldStrategy(), kinectPointCentroids);

            var realWorldObstCentroid = Calibration.Points.Find((x) => x.Name == "ObstacleCentroid").RealWorldPoint;
            var vectorRealWorldObstCentroid = realWorldObstCentroid.ToVector3D();

            var vectorAreaObstCentroid = ChangeOfBasis.GetVectorInNewBasis(vectorRealWorldObstCentroid);
            areaPointObstCentroid = new AreaPoint { X = (int)vectorAreaObstCentroid.X, Y = (int)vectorAreaObstCentroid.Y };

            Calibration.Points.Find((x) => x.Name == "ObstacleCentroid").AreaPoint = areaPointObstCentroid;
        }
        public void RealWorldToAreaEdge()
        {
            var a = Points.Find((e) => e.Name == "A");
            var b = Points.Find((e) => e.Name == "B");
            var c = Points.Find((e) => e.Name == "C");
            var d = Points.Find((e) => e.Name == "D");

            var realWorldPointA = a.RealWorldPoint;
            var realWorldPointB = b.RealWorldPoint;
            var realWorldPointC = c.RealWorldPoint;
            var realWorldPointD = d.RealWorldPoint;

            var vectorRealWorldA = realWorldPointA.ToVector3D();
            var vectorRealWorldB = realWorldPointB.ToVector3D();
            var vectorRealWorldC = realWorldPointC.ToVector3D();
            var vectorRealWorldD = realWorldPointD.ToVector3D();

            var coordinateSystemPoints = GetOriginPoint(vectorRealWorldA, vectorRealWorldB, vectorRealWorldC, vectorRealWorldD);
            ChangeOfBasis.InitializeChangeOfBasis(coordinateSystemPoints[1], coordinateSystemPoints[0], coordinateSystemPoints[2]);

            var vectorAreaA = ChangeOfBasis.GetVectorInNewBasis(vectorRealWorldA);
            var vectorAreaB = ChangeOfBasis.GetVectorInNewBasis(vectorRealWorldB);
            var vectorAreaC = ChangeOfBasis.GetVectorInNewBasis(vectorRealWorldC);
            var vectorAreaD = ChangeOfBasis.GetVectorInNewBasis(vectorRealWorldD);

            var areaPointA = new AreaPoint { X = (int)vectorAreaA.X, Y = (int)vectorAreaA.Y };
            var areaPointB = new AreaPoint { X = (int)vectorAreaB.X, Y = (int)vectorAreaB.Y };
            var areaPointC = new AreaPoint { X = (int)vectorAreaC.X, Y = (int)vectorAreaC.Y };
            var areaPointD = new AreaPoint { X = (int)vectorAreaD.X, Y = (int)vectorAreaD.Y };

            realWorldToArea.Add(realWorldPointA, areaPointA);
            realWorldToArea.Add(realWorldPointB, areaPointB);
            realWorldToArea.Add(realWorldPointC, areaPointC);
            realWorldToArea.Add(realWorldPointD, areaPointD);

            a.AreaPoint = areaPointA;
            b.AreaPoint = areaPointB;
            c.AreaPoint = areaPointC;
            d.AreaPoint = areaPointD;
        }
 public void ColorizePoint(int x, int y, Color color)
 {
     area[x, y] = new AreaPoint { Color = color, X = x, Y = y };
 }