コード例 #1
0
        private Vector3 CalculateGyroCursorPosition(Quaternion rotation)
        {
            Quaternion rotationDiff = lastRotationInv * rotation;

            lastRotationInv = Quaternion.Inverse(rotation);

            Vector3 rotPosNeg = RotationProvider.RotAsPosNeg(rotationDiff);

            Rect pointerLocation = GyroPointer.pixelInset;

            pointerLocation.x += MultiplierX * CDFunction(rotPosNeg.y);
            pointerLocation.y += MultiplierY * CDFunction(rotPosNeg.x * -1);

            //limits
            Vector2 minValues = new Vector2(-1 * (Screen.width / 4 + GyroPointer.pixelInset.width / 2),
                                            -1 * (Screen.height / 2 + GyroPointer.pixelInset.height / 2));
            Vector2 maxValues = new Vector2(Screen.width / 4 - GyroPointer.pixelInset.width / 2,
                                            Screen.height / 2 - GyroPointer.pixelInset.height / 2);

            Rect boundedPointerLocation = pointerLocation;

            boundedPointerLocation.x = Mathf.Max(minValues.x, Mathf.Min(maxValues.x, pointerLocation.x));
            boundedPointerLocation.y = Mathf.Max(minValues.y, Mathf.Min(maxValues.y, pointerLocation.y));

            return(boundedPointerLocation.position);
        }
コード例 #2
0
        void ComputeGyroPointer(Quaternion rotation)
        {
            Quaternion rotationDiff = lastRotationInv * rotation;

            lastRotationInv = Quaternion.Inverse(rotation);

            Vector3 rotPosNeg = RotationProvider.RotAsPosNeg(rotationDiff);

            Rect pointerLocation = HeadPointer.pixelInset;

            pointerLocation.x += MultiplierX * CDFunction(rotPosNeg.y);
            pointerLocation.y += MultiplierY * CDFunction(rotPosNeg.x * -1);
            ApplyMinMaxBoundaries(ref pointerLocation);

            HeadPointer.pixelInset = pointerLocation;
        }
コード例 #3
0
        static bool CheckCircularPrime(int num)
        {
            int[]        digits    = NumberUtils.SplitNumber(num, 1);
            List <int[]> numDigits = RotationProvider.BuildRotations <int>(digits);

            foreach (int[] newDigits in numDigits)
            {
                int num2 = 0;
                for (int i = 0; i < newDigits.Length; i++)
                {
                    num2 += newDigits[i] * (int)Math.Pow(10, i);
                }
                if (!primeMark[num2])
                {
                    return(false);
                }
            }
            return(true);
        }