Exemple #1
0
 public Exhibition(string name, string path, GeometryHandler.Plane plane)
 {
     this.name = name;
     this.path = path;
     this.exhibitionPlane = plane;
     this.exhibits = new List<Exhibit>();
 }
Exemple #2
0
        public SessionHandler(uint id, Point3D userPosition, double radius, GeometryHandler.Plane plane, Point3D screenSize, int bufferSize)
        {
            this.id = id;
            this.userPosition = userPosition;
            this.radius = radius;
            this.screenSize = screenSize;
            this.feedbackPositionBufferSize = bufferSize;
            this.feedbackPositionBuffer = new Queue<Point3D>(this.feedbackPositionBufferSize);

            initPlane(plane);
            initScreen();
        }
Exemple #3
0
        public Point3D definePosition(GeometryHandler.Plane plane, List<GeometryHandler.Vector> samples, int positions, int mode)
        {
            int points = pointsToDefine(samples.Count, positions, mode);
            sortAvgSamples(ref samples, points, mode);

            List<Point3D> pointPositions = new List<Point3D>(); // Pointing intersections from pointOnPlane-calculation
            List<Point3D> aimPositions = new List<Point3D>(); // Aiming intersections from pointOnPlane-calculation
            List<Point3D> combinedPoints = new List<Point3D>();
            Point3D combinedPoint = new Point3D();

            switch (mode)
            {
                case 0: // Only (pointing-)samples
                    foreach (GeometryHandler.Vector vector in samples)
                    {
                        combinedPoints.Add(this.geometryHandler.intersectVectorPlane(plane, vector));
                    }
                    break;
                case 1: // Only (aiming-)samples
                    foreach (GeometryHandler.Vector vector in samples)
                    {
                        combinedPoints.Add(this.geometryHandler.intersectVectorPlane(plane, vector));
                    }
                    break;
                case 2: // Both kinds of samples
                    List<GeometryHandler.Vector> pointAvgVectors = new List<GeometryHandler.Vector>();
                    List<GeometryHandler.Vector> aimAvgVectors = new List<GeometryHandler.Vector>();

                    int cnt = 0;
                    foreach (GeometryHandler.Vector sample in samples)
                    {
                        if (cnt < (samples.Count / 2))
                            pointPositions.Add(this.geometryHandler.intersectVectorPlane(plane, sample));
                        else
                            aimPositions.Add(this.geometryHandler.intersectVectorPlane(plane, sample));
                        ++cnt;
                    }

                    combinedPoints = this.geometryHandler.classifyCombined(pointPositions, aimPositions);
                    break;
                default: // Undefined mode
                    break; // Empty
            }
            combinedPoint = this.geometryHandler.getCenter(combinedPoints);

            return combinedPoint;
        }
Exemple #4
0
        public Point3D getBufferedPosition(GeometryHandler.Vector vector)
        {
            DateTime start = DateTime.Now;
            XNA.Vector3 vS = this.geometryHandler.makeVector3(vector.Start);
            XNA.Vector3 vD = this.geometryHandler.makeVector3(vector.Direction);

            double s = (double)XNA.Vector3.Dot(this.plane.Normal, (planeStart - vS)) / XNA.Vector3.Dot(this.plane.Normal, vD);

            Point3D intersection = vector.Start + (s * vector.Direction);
            this.feedbackPositionBuffer.Enqueue(intersection);

            if (this.feedbackPositionBuffer.Count == this.feedbackPositionBufferSize) // Buffer not at predefined size
            {
                this.feedbackPositionBuffer.Dequeue(); // Remove first Point from queue
            }

            return this.geometryHandler.getCenter(this.feedbackPositionBuffer);
        }
Exemple #5
0
 public void setExhibitionPlane(GeometryHandler.Plane plane)
 {
     this.exhibitionPlane = plane;
 }
Exemple #6
0
        private List<Point3D> makeLookupPositions(GeometryHandler.Plane plane)
        {
            List<Point3D> planePositions = new List<Point3D>();
            Point3D tmpPos = plane.Start;
            double steps = 1000; // ~3mm steps, at least in lab's exhibition plane(1800x1800mm)
            double lambdaDir1;
            double lambdaDir2;

            planePositions.Add(tmpPos);
            for (int stepDir1 = 0; stepDir1 != steps; ++stepDir1) // Over (twice) the first direction of the plane, make 1000(=: 2.0/stepSize) steps
            {
                for (int stepDir2 = 0; stepDir2 != steps; ++stepDir2) // Over (twice) the second direction of the plane, make 1000(=: 2.0/stepSize) steps
                {
                    lambdaDir1 = (stepDir1 + 1) / steps;
                    lambdaDir2 = (stepDir2 + 1) / steps;
                    tmpPos = plane.Start + (lambdaDir1 * plane.Direction1) + (lambdaDir2 * plane.Direction2);
                    planePositions.Add(tmpPos);
                }
            }

            return planePositions;
        }
Exemple #7
0
        public void makeLookupTable(List<Exhibit> exhibits, GeometryHandler.Plane exhibitionPlane)
        {
            this.lookup = new Dictionary<Point3D, int>();
            Dictionary<int, int> checkup = new Dictionary<int, int>();
            List<Point3D> positions = makeLookupPositions(exhibitionPlane);
            List<double> weightsForPosition = new List<double>();

            foreach (Point3D position in positions) // Lookup-key
            {
                weightsForPosition.Clear();

                foreach (Exhibit exhibit in exhibits)
                {
                    weightsForPosition.Add(getKernelWeight(position, exhibit.getPosition(), exhibit.getKernelSize(), exhibit.getKernelWeight()));
                }

                this.lookup.Add(position, getMaxIndex(weightsForPosition));
            }

            foreach (KeyValuePair<Point3D, int> position in this.lookup)
            {
                if (checkup.ContainsKey(position.Value) == false)
                {
                    checkup.Add(position.Value, 1);
                }
                else
                {
                    ++checkup[position.Value];
                }
            }
        }
Exemple #8
0
 public void initPlane(GeometryHandler.Plane plane)
 {
     // Plane
     this.planeStart = new XNA.Vector3((float)plane.Start.X, (float)plane.Start.Y, (float)plane.Start.Z);
     this.planeEnd1 = new XNA.Vector3((float)plane.End1.X, (float)plane.End1.Y, (float)plane.End1.Z);
     this.planeEnd2 = new XNA.Vector3((float)plane.End2.X, (float)plane.End2.Y, (float)plane.End2.Z);
     this.planeDir1 = new XNA.Vector3((float)plane.Direction1.X, (float)plane.Direction1.Y, (float)plane.Direction1.Z);
     this.planeDir2 = new XNA.Vector3((float)plane.Direction2.X, (float)plane.Direction2.Y, (float)plane.Direction2.Z);
     this.plane = new XNA.Plane(planeStart, planeEnd1, planeEnd2);
     this.planeNormal = this.plane.Normal;
 }
Exemple #9
0
        public void saveExhibitionPlane(GeometryHandler.Plane exhibitionPlane)
        {
            string path = this.exhibitionFolder + "_Plane.xml";
            XmlWriter exhibitionPlaneWriter = XmlWriter.Create(path, this.xmlWriterSettings);

            //<ExhibitionPlane>
            exhibitionPlaneWriter.WriteStartElement("ExhibitionPlane");
            //<Corner> #1
            exhibitionPlaneWriter.WriteStartElement("Corner");
            exhibitionPlaneWriter.WriteAttributeString("Position", exhibitionPlane.Start.ToString().Replace(',', '.').Replace(';', ' '));
            exhibitionPlaneWriter.WriteEndElement();
            //</Corner> #1
            //<Corner> #2
            exhibitionPlaneWriter.WriteStartElement("Corner");
            exhibitionPlaneWriter.WriteAttributeString("Position", exhibitionPlane.End1.ToString().Replace(',', '.').Replace(';', ' '));
            exhibitionPlaneWriter.WriteEndElement();
            //</Corner> #2
            //<Corner> #3
            exhibitionPlaneWriter.WriteStartElement("Corner");
            exhibitionPlaneWriter.WriteAttributeString("Position", exhibitionPlane.End2.ToString().Replace(',', '.').Replace(';', ' '));
            exhibitionPlaneWriter.WriteEndElement();
            //</Corner> #3
            exhibitionPlaneWriter.WriteEndElement();
            //</ExhibitionPlane>

            exhibitionPlaneWriter.WriteEndDocument(); // Stop writing the file
            exhibitionPlaneWriter.Close(); // Close the file
        }
Exemple #10
0
        public Point3D getPosition(GeometryHandler.Vector vector)
        {
            XNA.Vector3 vS = this.geometryHandler.makeVector3(vector.Start);
            XNA.Vector3 vD = this.geometryHandler.makeVector3(vector.Direction);

            double s = (double)XNA.Vector3.Dot(this.plane.Normal, (planeStart - vS)) / XNA.Vector3.Dot(this.plane.Normal, vD);

            Point3D intersection = vector.Start + (s * vector.Direction);

            return intersection;
        }
Exemple #11
0
 private void initHandlers()
 {
     this.geometryHandler = new GeometryHandler();
     this.fileHandler = new FileHandler();
 }
Exemple #12
0
 public CalibrationHandler(int samplingVectors, double threshold)
 {
     this.geometryHandler = new GeometryHandler();
     this.samplesPerPosition = samplingVectors;
     this.threshold = threshold;
 }
Exemple #13
0
        double threshold = 100; // Default := 100mm

        #endregion Fields

        #region Constructors

        public CalibrationHandler(int samplingVectors)
        {
            this.geometryHandler = new GeometryHandler();
            this.samplesPerPosition = samplingVectors;
        }
Exemple #14
0
        public bool validatePlane(GeometryHandler.Plane plane1, GeometryHandler.Plane plane2)
        {
            int sum = withinThreshold(plane1.Start, plane2.Start) + withinThreshold(plane1.End1, plane2.End1) + withinThreshold(plane1.End2, plane2.End2);

            if (sum > 7) // 8 or 9 axis' values within threshold
                return true;
            else
                return false;
        }
Exemple #15
0
        public GeometryHandler.Plane makePlane(GeometryHandler.Plane plane1, GeometryHandler.Plane plane2)
        {
            GeometryHandler.Plane plane = new GeometryHandler.Plane(geometryHandler.getCenter(plane1.Start, plane2.Start), geometryHandler.getCenter(plane1.End1, plane2.End1), geometryHandler.getCenter(plane1.End2, plane2.End2));

            return plane;
        }
Exemple #16
0
        public int getTarget(GeometryHandler.Vector vector)
        {
            Point3D pos = getPosition(vector);

            return getClosestIndex(pos);
        }
Exemple #17
0
 public Exhibition(string name, GeometryHandler.Plane plane, List<Exhibit> exhibits)
 {
     this.name = name;
     this.exhibitionPlane = plane;
     this.exhibits = exhibits;
 }
Exemple #18
0
        private uint USER_ID = 1; // DO NOT TOUCH ! ! !

        #endregion Fields

        #region Constructors

        public MainWindow()
        {
            InitializeComponent();

            // Initialize tracking
            initJoints();
            this.tracking = false; // Turn off tracking
            this.calibrating = false; // Turn off any calibration

            // Initialize dialogs
            initDialogs();

            // Initialize handlers
            this.geometryHandler = new GeometryHandler();
            this.fileHandler = new FileHandler();

            // Initialize layout
            this.headline = Headline.Start;
            this.setting = Setting.None;
            updateLayout();
        }