Exemplo n.º 1
0
        private Ray3D calibrateDeviceOnePosition(int user, byte device)
        {
            UserPrompt.Write("Turning on device " + device);

            Device.turnOn(device);
            Thread.Sleep(CALIBRATION_OFFSET_SEC * 1000);
            Vector3D[] headPoints      = new Vector3D[STEADY_SEC * SAMPLES_PER_SEC];
            Vector3D[] rightHandPoints = new Vector3D[STEADY_SEC * SAMPLES_PER_SEC];

            // Sample the user's hopefully steady hand.
            SkeletonJointPosition head      = new SkeletonJointPosition();
            SkeletonJointPosition rightHand = new SkeletonJointPosition();

            for (int i = 0; i < STEADY_SEC * SAMPLES_PER_SEC; i++)
            {
                head               = userGenerator.SkeletonCapability.GetSkeletonJointPosition(user, SkeletonJoint.Head);
                rightHand          = userGenerator.SkeletonCapability.GetSkeletonJointPosition(user, SkeletonJoint.RightHand);
                headPoints[i]      = new Vector3D(head.Position.X, head.Position.Y, head.Position.Z);
                rightHandPoints[i] = new Vector3D(rightHand.Position.X, rightHand.Position.Y, rightHand.Position.Z);
            }
            Thread.Sleep((CALIBRATION_SEC - STEADY_SEC - CALIBRATION_OFFSET_SEC) * 1000);

            // Take the averages of each side.
            Vector3D averageHeadPoint = new Vector3D(headPoints.Average(x => x.X),
                                                     headPoints.Average(x => x.Y), headPoints.Average(x => x.Z));
            Vector3D averageRightHandPoint = new Vector3D(rightHandPoints.Average(x => x.X),
                                                          rightHandPoints.Average(x => x.Y), rightHandPoints.Average(x => x.Z));

            UserPrompt.Write("Turning off device " + device);

            Device.turnOff(device);
            return(new Ray3D(averageHeadPoint, averageRightHandPoint));
        }
Exemplo n.º 2
0
        private void CreateUmbrellaFigure()
        {
            // ЗОНТИК

            // шляпка
            var triangle1 = new Triangle3D(
                new Vector3D(-200, 0, 1000),
                new Vector3D(0, 200, 1000),
                new Vector3D(0, 0, 1200),
                Color.Blue);

            var triangle2 = new Triangle3D(
                new Vector3D(0, 200, 1000),
                new Vector3D(200, 0, 1000),
                new Vector3D(0, 0, 1200),
                Color.Red);

            var triangle3 = new Triangle3D(
                new Vector3D(200, 0, 1000),
                new Vector3D(0, -200, 1000),
                new Vector3D(0, 0, 1200),
                Color.Magenta);

            var triangle4 = new Triangle3D(
                new Vector3D(0, -200, 1000),
                new Vector3D(-200, 0, 1000),
                new Vector3D(0, 0, 1200),
                Color.Lime);

            // ножка

            Func <Vector3D, Vector3D, Vector3D, double> spinDeepPoint = (v1, v2, v3) =>
            {
                return(Math.Sqrt(v3.X * v3.X + v3.Y * v3.Y + v3.Z * v3.Z));
            };

            var triangle5 = new Triangle3D(
                new Vector3D(-20, 20, 800),
                new Vector3D(20, 20, 800),
                new Vector3D(0, 0, 1200),
                Color.Chocolate, spinDeepPoint);

            var triangle6 = new Triangle3D(
                new Vector3D(-20, -20, 800),
                new Vector3D(-20, 20, 800),
                new Vector3D(0, 0, 1200),
                Color.Chocolate, spinDeepPoint);

            var triangle7 = new Triangle3D(
                new Vector3D(20, -20, 800),
                new Vector3D(-20, -20, 800),
                new Vector3D(0, 0, 1200),
                Color.Chocolate, spinDeepPoint);

            var triangle8 = new Triangle3D(
                new Vector3D(20, 20, 800),
                new Vector3D(20, -20, 800),
                new Vector3D(0, 0, 1200),
                Color.Chocolate, spinDeepPoint);

            var triangle9 = new Triangle3D(
                new Vector3D(-20, -20, 800),
                new Vector3D(20, 20, 800),
                new Vector3D(-20, 20, 800),
                Color.Chocolate);

            var triangle10 = new Triangle3D(
                new Vector3D(20, 20, 800),
                new Vector3D(-20, -20, 800),
                new Vector3D(20, -20, 800),
                Color.Chocolate);

            _scene3D.Append(triangle1);
            _scene3D.Append(triangle2);
            _scene3D.Append(triangle3);
            _scene3D.Append(triangle4);
            _scene3D.Append(triangle5);
            _scene3D.Append(triangle6);
            _scene3D.Append(triangle7);
            _scene3D.Append(triangle8);
            _scene3D.Append(triangle9);
            _scene3D.Append(triangle10);

            var averagePosition = Vector3D.Average(
                triangle1.OrientationVector,
                triangle2.OrientationVector,
                triangle3.OrientationVector,
                triangle4.OrientationVector,
                triangle5.OrientationVector,
                triangle6.OrientationVector,
                triangle7.OrientationVector,
                triangle8.OrientationVector,
                triangle9.OrientationVector,
                triangle10.OrientationVector);

            _scene3D.SetObjectPosition(averagePosition);
        }