コード例 #1
0
        public static Pix Pivot(Pix pix, float angle, RotationMethod method = RotationMethod.AreaMap, RotationFill fillColor = RotationFill.White, int?w = null, int?h = null)
        {
            w = w.IsNullOrEmpty() ? pix.Width : w;
            h = h.IsNullOrEmpty() ? pix.Height : h;
            if (Math.Abs(angle) < TinyAngle)
            {
                return(pix.Clone());
            }
            IntPtr p;

            double rotations = 2 * angle / Math.PI;

            if (Math.Abs(rotations - Math.Floor(rotations)) < TinyAngle)
            {
                p = LeptonicaNativeApi.Native.pixRotateOrth(pix.Reference, (int)rotations);
            }
            else
            {
                p = LeptonicaNativeApi.Native.pixRotate(pix.Reference, angle, method, fillColor, w.Value, h.Value);
            }
            if (p == IntPtr.Zero)
            {
                throw new NullReferenceException("failed to rotate");
            }
            return(Pix.Create(p));
        }
コード例 #2
0
ファイル: LeapRTS.cs プロジェクト: mihaimpop/vr-analytics
        private void doRotationMethodGUI(ref RotationMethod rotationMethod)
        {
            GUILayout.BeginHorizontal();

            GUI.color = rotationMethod == RotationMethod.None ? Color.green : Color.white;
            if (GUILayout.Button("No Rotation"))
            {
                rotationMethod = RotationMethod.None;
            }

            GUI.color = rotationMethod == RotationMethod.Single ? Color.green : Color.white;
            if (GUILayout.Button("Single Axis"))
            {
                rotationMethod = RotationMethod.Single;
            }

            GUI.color = rotationMethod == RotationMethod.Full ? Color.green : Color.white;
            if (GUILayout.Button("Full Rotation"))
            {
                rotationMethod = RotationMethod.Full;
            }

            GUI.color = Color.white;

            GUILayout.EndHorizontal();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: juliavav/NumMethLab
        private static void Lab4()
        {
            ReadingService.ReadLab4();
            var A      = new matrix(Lab4Matrix);
            var answer = new RotationMethod(A).GetAnswer();

            Console.WriteLine("U matrix:");
            answer.Print();
        }
コード例 #4
0
 protected virtual void Start()
 {
     currentMovement       = MoveTank;
     currentRotationMethod = RotateTank;
     specialAttackMethods  = new SpecialAttackMethod[] { FireMissile, SpawnShield, SpeedBoost, Heal, SuperHeal, DeployMine, SuperShots };
     currentSpecialAttack  = Nothing;
     directSliderTF        = healthSlider.gameObject.GetComponentInParent <Transform>();
     delayedSliderTF       = healthSliderDelayed.gameObject.GetComponentInParent <Transform>();
     InitializeStats();
 }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (this.targetMetadataParser.ProjectName == null || this.targetMetadataParser.ProjectName == "")
        {
            this.targetMetadataParser.ProjectName     = this.projectName;
            this.targetMetadataParser.csvMetadataFile = this.csvMetadataFile;
        }

        if (this.targetMetadataParser.output != null && !this.createdQuads)
        {
            this.rootDir = this.projectName;
            if (!(rootDir.EndsWith("/") || rootDir.EndsWith("//")))
            {
                rootDir += "/";
            }
            this.createQuads();
            this.createdQuads = true;
        }

        if (this.visualizationScale != this._visualizationScale && this.canUpdateLive)
        {
            this._visualizationScale = this.visualizationScale;
            this.calculateQuadPositions();
        }

        if (this.rotateAll != this._rotateAll && this.canUpdateLive)
        {
            this._rotateAll = this.rotateAll;
            this.calculateQuadPositions();
        }

        if (this.quadScale != this._quadScale && this.canUpdateLive)
        {
            this._quadScale = this.quadScale;
            this.rescaleQuads();
        }

        if (this.rotationMethod != this._rotationMethod && this.canUpdateLive)
        {
            this._rotationMethod = this.rotationMethod;
            this.calculateQuadPositions();
        }

        if ((!writtenHeights) && Input.GetKey("h"))
        {
            writtenHeights = true;
            Debug.Log("print heights");
            System.IO.StreamWriter file = new System.IO.StreamWriter("d:\\heights_" + csvMetadataFile.name + ".csv");
            foreach (MetaDataItem mdi in this.targetMetadataParser.output)
            {
                file.WriteLine(mdi.transform.position.y + "," + mdi.filename);
            }
            file.Close();
        }
    }
コード例 #6
0
 protected override void HandleRotateBody(RotationMethod method)
 {
     if (References.NetworkIdentity.hasAuthority == false)
     {
         return;
     }
     else
     {
         base.HandleRotateBody(method);
     }
 }
コード例 #7
0
 public static Pix PixRotate(this Pix pix, float angle, float confidence, RotationMethod method = RotationMethod.Shear, RotationFill fill = RotationFill.White)
 {
     if (pix == null)
     {
         throw new ArgumentNullException("pix is null");
     }
     if (IsRotationConfident(confidence))
     {
         IntPtr pixPtr = LeptonicaNativeApi.Native.pixRotate(pix.Reference, angle.DegreeToRadians(), method, fill, pix.Width, pix.Height);
         return(Pix.Create(pixPtr));
     }
     return(pix);
 }
コード例 #8
0
            protected virtual void HandleRotateBody(RotationMethod method)
            {
                switch (method)
                {
                case RotationMethod.TowardMoveInput:
                    HandleRotateTowardMoveInput();
                    break;

                case RotationMethod.TowardAim:
                    HandleRotateTowardAim();
                    break;

                case RotationMethod.TowardVelocity:
                    HandleRotateTowardVelocity();
                    break;
                }
            }
コード例 #9
0
        /// <summary>
        /// Creates a new image by rotating this image about it's centre.
        /// </summary>
        /// <remarks>
        /// Please note the following:
        /// <list type="bullet">
        /// <item>
        /// Rotation will bring in either white or black pixels, as specified by <paramref name="fillColor" /> from
        /// the outside as required.
        /// </item>
        /// <item>Above 20 degrees, sampling rotation will be used if shear was requested.</item>
        /// <item>Colormaps are removed for rotation by area map and shear.</item>
        /// <item>
        /// The resulting image can be expanded so that no image pixels are lost. To invoke expansion,
        /// input the original width and height. For repeated rotation, use of the original width and heigh allows
        /// expansion to stop at the maximum required size which is a square of side = sqrt(w*w + h*h).
        /// </item>
        /// </list>
        /// <para>
        /// Please note there is an implicit assumption about RGB component ordering.
        /// </para>
        /// </remarks>
        /// <param name="angle">The angle to rotate by, in radians; clockwise is positive.</param>
        /// <param name="method">The rotation method to use.</param>
        /// <param name="fillColor">The fill color to use for pixels that are brought in from the outside.</param>
        /// <param name="width">The original width; use 0 to avoid embedding</param>
        /// <param name="height">The original height; use 0 to avoid embedding</param>
        /// <returns>The image rotated around it's centre.</returns>
        public Pix Rotate(float angle, RotationMethod method = RotationMethod.AreaMap, RotationFill fillColor = RotationFill.White, int?width = null, int?height = null)
        {
            if (width == null)
            {
                width = this.Width;
            }
            if (height == null)
            {
                height = this.Height;
            }

            if (Math.Abs(angle) < VerySmallAngle)
            {
                return(this.Clone());
            }

            IntPtr resultHandle;

            var rotations = 2 * angle / Math.PI;

            // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
            if (Math.Abs(rotations - Math.Floor(rotations)) < VerySmallAngle)
            {
                // handle special case of orthoganal rotations (90, 180, 270)
                resultHandle = LeptonicaApi.Native.pixRotateOrth(this.Handle, ( int )rotations);
            }
            else
            {
                // handle general case
                resultHandle = LeptonicaApi.Native.pixRotate(this.Handle, angle, method, fillColor, width.Value, height.Value);
            }

            if (resultHandle == IntPtr.Zero)
            {
                throw new LeptonicaException("Failed to rotate image around it's centre.");
            }

            return(new Pix(resultHandle));
        }
コード例 #10
0
        /// <summary>
        /// Creates a new image by rotating this image about it's centre.
        /// </summary>
        /// <remarks>
        /// Please note the following:
        /// <list type="bullet">
        /// <item>
        /// Rotation will bring in either white or black pixels, as specified by <paramref name="fillColor" /> from
        /// the outside as required.
        /// </item>
        /// <item>Above 20 degrees, sampling rotation will be used if shear was requested.</item>
        /// <item>Colormaps are removed for rotation by area map and shear.</item>
        /// <item>
        /// The resulting image can be expanded so that no image pixels are lost. To invoke expansion,
        /// input the original width and height. For repeated rotation, use of the original width and heigh allows
        /// expansion to stop at the maximum required size which is a square of side = sqrt(w*w + h*h).
        /// </item>
        /// </list>
        /// <para>
        /// Please note there is an implicit assumption about RGB component ordering.
        /// </para>
        /// </remarks>
        /// <param name="angleInRadians">The angle to rotate by, in radians; clockwise is positive.</param>
        /// <param name="method">The rotation method to use.</param>
        /// <param name="fillColor">The fill color to use for pixels that are brought in from the outside.</param>
        /// <param name="width">The original width; use 0 to avoid embedding</param>
        /// <param name="height">The original height; use 0 to avoid embedding</param>
        /// <returns>The image rotated around it's centre.</returns>
        public Pix Rotate(float angleInRadians, RotationMethod method = RotationMethod.AreaMap, RotationFill fillColor = RotationFill.White, int?width = null, int?height = null)
        {
            if (width == null)
            {
                width = this.Width;
            }
            if (height == null)
            {
                height = this.Height;
            }

            if (Math.Abs(angleInRadians) < VerySmallAngle)
            {
                return(this.Clone());
            }

            IntPtr resultHandle;

            var rotations = 2 * angleInRadians / Math.PI;

            if (Math.Abs(rotations - Math.Floor(rotations)) < VerySmallAngle)
            {
                // handle special case of orthoganal rotations (90, 180, 270)
                resultHandle = Interop.LeptonicaApi.Native.pixRotateOrth(handle, (int)rotations);
            }
            else
            {
                // handle general case
                resultHandle = Interop.LeptonicaApi.Native.pixRotate(handle, angleInRadians, method, fillColor, width.Value, height.Value);
            }

            if (resultHandle == IntPtr.Zero)
            {
                throw new LeptonicaException("Failed to rotate image around its centre.");
            }

            return(new Pix(resultHandle));
        }
コード例 #11
0
ファイル: LeapRTS.cs プロジェクト: emomper23/PsychVR
        private void doRotationMethodGUI(ref RotationMethod rotationMethod)
        {
            GUILayout.BeginHorizontal();

              GUI.color = rotationMethod == RotationMethod.None ? Color.green : Color.white;
              if (GUILayout.Button("No Rotation")) {
            rotationMethod = RotationMethod.None;
              }

              GUI.color = rotationMethod == RotationMethod.Single ? Color.green : Color.white;
              if (GUILayout.Button("Single Axis")) {
            rotationMethod = RotationMethod.Single;
              }

              GUI.color = rotationMethod == RotationMethod.Full ? Color.green : Color.white;
              if (GUILayout.Button("Full Rotation")) {
            rotationMethod = RotationMethod.Full;
              }

              GUI.color = Color.white;

              GUILayout.EndHorizontal();
        }
コード例 #12
0
ファイル: Pix.cs プロジェクト: nonameShadow/tesseract
        /// <summary>
        /// Creates a new image by rotating this image about it's centre.
        /// </summary>
        /// <remarks>
        /// Please note the following:
        /// <list type="bullet">
        /// <item>
        /// Rotation will bring in either white or black pixels, as specified by <paramref name="fillColor" /> from
        /// the outside as required.
        /// </item>
        /// <item>Above 20 degrees, sampling rotation will be used if shear was requested.</item>
        /// <item>Colormaps are removed for rotation by area map and shear.</item>
        /// <item>
        /// The resulting image can be expanded so that no image pixels are lost. To invoke expansion,
        /// input the original width and height. For repeated rotation, use of the original width and heigh allows
        /// expansion to stop at the maximum required size which is a square of side = sqrt(w*w + h*h).
        /// </item>
        /// </list>
        /// <para>
        /// Please note there is an implicit assumption about RGB component ordering.
        /// </para>
        /// </remarks>
        /// <param name="angle">The angle to rotate by, in radians; clockwise is positive.</param>
        /// <param name="method">The rotation method to use.</param>
        /// <param name="fillColor">The fill color to use for pixels that are brought in from the outside.</param>
        /// <param name="width">The original width; use 0 to avoid embedding</param>
        /// <param name="height">The original height; use 0 to avoid embedding</param>
        /// <returns>The image rotated around it's centre.</returns>
        public Pix Rotate(float angle, RotationMethod method = RotationMethod.AreaMap, RotationFill fillColor = RotationFill.White, int? width = null, int? height = null)
        {
            if(width == null) width = this.Width;
            if(height == null) height = this.Height;

            if(Math.Abs(angle) < VerySmallAngle) return this.Clone();

            IntPtr resultHandle;

            var rotations = 2 * angle / Math.PI;
            if(Math.Abs(rotations - Math.Floor(rotations)) < VerySmallAngle) {
                // handle special case of orthoganal rotations (90, 180, 270)
                resultHandle = Interop.LeptonicaApi.Native.pixRotateOrth(handle, (int)rotations);
            } else {
                // handle general case
                resultHandle = Interop.LeptonicaApi.Native.pixRotate(handle, angle, method, fillColor, width.Value, height.Value);
            }

            if(resultHandle == IntPtr.Zero) throw new LeptonicaException("Failed to rotate image around it's centre.");

            return new Pix(resultHandle);
        }
コード例 #13
0
    // Update is called once per frame
    void Update()
    {
        if (this.targetMetadataParser.ProjectName == null || this.targetMetadataParser.ProjectName == "") {
            this.targetMetadataParser.ProjectName = this.projectName;
            this.targetMetadataParser.csvMetadataFile = this.csvMetadataFile;
        }

        if (this.targetMetadataParser.output != null && !this.createdQuads) {
            this.rootDir = this.projectName;
            if (!(rootDir.EndsWith("/") || rootDir.EndsWith("//"))) {
                rootDir += "/";
            }
            this.createQuads();
            this.createdQuads = true;
        }

        if (this.visualizationScale != this._visualizationScale && this.canUpdateLive) {
            this._visualizationScale = this.visualizationScale;
            this.calculateQuadPositions();
        }

        if (this.rotateAll != this._rotateAll && this.canUpdateLive) {
            this._rotateAll = this.rotateAll;
            this.calculateQuadPositions();
        }

        if (this.quadScale != this._quadScale && this.canUpdateLive) {
            this._quadScale = this.quadScale;
            this.rescaleQuads();
        }

        if (this.rotationMethod != this._rotationMethod && this.canUpdateLive) {
            this._rotationMethod = this.rotationMethod;
            this.calculateQuadPositions();
        }

        if ((!writtenHeights) && Input.GetKey ("h"))
        {
            writtenHeights = true;
            Debug.Log ("print heights");
            System.IO.StreamWriter file = new System.IO.StreamWriter("d:\\heights_" + csvMetadataFile.name + ".csv");
            foreach (MetaDataItem mdi in this.targetMetadataParser.output) {

                file.WriteLine(mdi.transform.position.y + "," + mdi.filename);
            }
            file.Close();
        }
    }
コード例 #14
0
 IntPtr pixRotate(IntPtr pixs, float angle, RotationMethod type, RotationFill fillColor, int width, int heigh);
コード例 #15
0
    // Update is called once per frame
    void Update()
    {
        if (this.targetMetadataParser.ProjectName == null || this.targetMetadataParser.ProjectName == "") {
            this.targetMetadataParser.ProjectName = this.projectName;
            this.targetMetadataParser.csvMetadataFile = this.csvMetadataFile;
        }

        if (this.targetMetadataParser.output != null && !this.createdQuads) {
            this.rootDir = this.projectName;
            if (!(rootDir.EndsWith("/") || rootDir.EndsWith("//"))) {
                rootDir += "/";
            }
            this.createQuads();
            this.createdQuads = true;
        }

        if (this.visualizationScale != this._visualizationScale && this.canUpdateLive) {
            this._visualizationScale = this.visualizationScale;
            this.calculateQuadPositions();
        }

        if (this.rotateAll != this._rotateAll && this.canUpdateLive) {
            this._rotateAll = this.rotateAll;
            this.calculateQuadPositions();
        }

        if (this.quadScale != this._quadScale && this.canUpdateLive) {
            this._quadScale = this.quadScale;
            this.rescaleQuads();
        }

        if (this.rotationMethod != this._rotationMethod && this.canUpdateLive) {
            this._rotationMethod = this.rotationMethod;
            this.calculateQuadPositions();
        }
    }
コード例 #16
0
 public static extern IntPtr pixRotate(HandleRef pixs, float angle, RotationMethod type, RotationFill fillColor, int width, int heigh);
コード例 #17
0
        /// <summary>
        /// Генерация квадратного шифра
        /// </summary>
        /// <param name="cipherLength"></param>
        /// <param name="rotationMethod"></param>
        /// <param name="gridType"></param>
        /// <returns></returns>
        public static Commons.Cipher GenerateCardanoGrid(int cipherLength, RotationMethod rotationMethod, GridType gridType)
        {
            int edge1 = 0;
            int edge2 = 0;

            int newMessageLength = 0;

            switch (gridType)
            {
            case GridType.Square:
                var edge = Math.Sqrt(cipherLength);
                if (edge % 1 != 0)
                {
                    foreach (var square in Enumerable.Range(2, 100).Where((x) => x % 2 == 0)
                             .Select(x => new long[] { x, x * x }))
                    {
                        if (square[1] <= cipherLength)
                        {
                            continue;
                        }

                        edge = square[0];
                        break;
                    }
                }

                if (edge % 2 != 0)
                {
                    edge++;
                }

                edge1 = Convert.ToInt32(edge);
                edge2 = edge1;
                break;

            case GridType.Rect:
                var tail = cipherLength % 2;
                if (tail != 0)
                {
                    cipherLength += tail;
                }

                edge1 = 2;
                edge2 = cipherLength / 2;
                if (edge2 % 2 != 0)
                {
                    edge2++;
                }

                while (edge2 / edge1 > 4)
                {
                    edge2 /= 2;
                    edge1 *= 2;
                }

                if (edge2 == edge1)
                {
                    edge1 /= 2;
                    edge2 *= 2;
                }
                if (edge2 % 2 != 0)
                {
                    edge2++;
                }

                break;
            }
            newMessageLength = edge1 * edge2;

            var cardanoGrid = new int[edge1, edge2];
            var rnd         = new Random();

            for (int a = 0; a < newMessageLength / 4; a++)
            {
                var availableRowsNumbersArray =
                    Enumerable.Range(0, edge1)
                    .Where((n) => cardanoGrid.GetRow(n).Contains(0)).ToArray();

                var randomRow = availableRowsNumbersArray[rnd.Next(0, availableRowsNumbersArray.Length - 1)];

                try
                {
                    var currentRow       = cardanoGrid.GetRow(randomRow);
                    var possibilityArray = Enumerable.Range(0, edge2)
                                           .Where((n) => currentRow[n] == 0).ToArray();

                    var rndInt = possibilityArray[rnd.Next(0, possibilityArray.Length - 1)];

                    var j = 1;
                    cardanoGrid[randomRow, rndInt] = 1;
                    do
                    {
                        switch (rotationMethod)
                        {
                        case RotationMethod.StraightAngle:
                            if (gridType is GridType.Rect)
                            {
                                goto case RotationMethod.OpenAngle;
                            }
                            cardanoGrid.Rotate90Clockwise();
                            break;

                        case RotationMethod.OpenAngle:
                            if (j % 2 == 0)
                            {
                                cardanoGrid.ReverseColumns();
                            }
                            else
                            {
                                cardanoGrid.ReverseRows();
                            }
                            break;
                        }
                        cardanoGrid[randomRow, rndInt] = -1;
                        j++;
                    } while (j < 4);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            return(new Commons.Cipher()
            {
                CipherGrid = cardanoGrid, RotationMethod = rotationMethod, GridType = gridType
            });
        }
コード例 #18
0
 internal static extern IntPtr pixRotate(HandleRef pixs, float angle, RotationMethod type, RotationFill fillColor, int width, int heigh);
コード例 #19
0
 public IRotation Get(RotationMethod rotation)
 => rotation
 switch
 {
コード例 #20
0
ファイル: Clock.cs プロジェクト: brookman/viscon-public
 void Start()
 {
     HandRotationMethod = GetComponent <RotationMethod>();
 }
コード例 #21
0
 public virtual IRotation Get(RotationMethod model)
 => _factory.Get(model);
コード例 #22
0
        /// <summary>
        /// This is called every frame by Player in order to tell the character what its inputs are.
        /// </summary>
        public void SetInputs(ref PlayerCharacterInputs playerInputs)
        {
            Vector3 _moveInputVector = Vector3.ClampMagnitude(new Vector3(playerInputs.MoveAxisRight, 0f, playerInputs.MoveAxisForward), 1f);

            float lookInput = 0;

            if (playerInputs.RotationMethod == RotationMethod.KeyboardRotation)
            {
                lookInput = Motor.transform.rotation.y + playerInputs.MoveAxisRight * 25f; //TODO: Replace hardcoding with proper sensitivity value
            }
            else if (playerInputs.RotationMethod == RotationMethod.MouseJoystick)
            {
                Vector3 mousePosition = new Vector3(Input.mousePosition.x / Screen.width, Input.mousePosition.y / Screen.height, 0);
                Vector3 screenCenter  = new Vector3(0.5f, 0.5f, 0);

                lookInput = Mathf.Atan2(mousePosition.y - screenCenter.y, mousePosition.x - screenCenter.x) * (180f / Mathf.PI);
            }

            #region Camera-Rotation

            Vector3 _cameraPlanarDirection = Vector3.ProjectOnPlane(playerInputs.CameraRotation * Vector3.forward, Motor.CharacterUp).normalized;
            if (_cameraPlanarDirection.sqrMagnitude == 0f)
            {
                _cameraPlanarDirection = Vector3.ProjectOnPlane(playerInputs.CameraRotation * Vector3.up, Motor.CharacterUp).normalized;
            }
            Quaternion cameraPlanarRotation = Quaternion.LookRotation(_cameraPlanarDirection, Motor.CharacterUp);

            #endregion

            #region Character-Rotation

            //LookInputVector = new Vector3(lookInput, 0, 0f);

            Quaternion rotationFromInput         = Quaternion.Euler(Motor.CharacterUp * lookInput);
            Vector3    _characterPlanarDirection = Vector3.Cross(Motor.CharacterUp,
                                                                 Vector3.Cross((rotationFromInput * Motor.CharacterForward),
                                                                               Motor.CharacterUp));
            Quaternion characterPlanarRotation = Quaternion.LookRotation(_characterPlanarDirection, Motor.CharacterUp);

            /*
             * Quaternion rotationFromInput = Quaternion.Euler(FollowTransform.up * (rotationInput.x * RotationSpeed));
             * PlanarDirection = rotationFromInput * PlanarDirection;
             * PlanarDirection = Vector3.Cross(FollowTransform.up, Vector3.Cross(PlanarDirection, FollowTransform.up));
             * Quaternion planarRot = Quaternion.LookRotation(PlanarDirection, FollowTransform.up);
             */


            #endregion

            //LookInputVector = new Vector3(lookInput, 0, 0f);

            switch (playerInputs.RotationMethod)
            {
            case (RotationMethod.NoRotation):
            {
                LookInputVector = _cameraPlanarDirection;
                break;
            }

            case (RotationMethod.KeyboardRotation):
            {
                //_moveInputVector = new Vector3(0, _moveInputVector.y, _moveInputVector.z);
                LookInputVector = _characterPlanarDirection;
                break;
            }

            case (RotationMethod.VelocityRotation):
            {
                LookInputVector = Motor.BaseVelocity;
                break;
            }

            case (RotationMethod.MouseJoystick):
            {
                //_moveInputVector = new Vector3(0, _moveInputVector.y, _moveInputVector.z);
                LookInputVector = _characterPlanarDirection;
                break;
            }
            }

            switch (playerInputs.MovementMethod)
            {
            case (MovementMethod.StaticForward):
            {
                MoveInputVector = _moveInputVector;
                break;
            }

            case (MovementMethod.CameraIsForward):
            {
                MoveInputVector = cameraPlanarRotation * _moveInputVector;
                break;
            }

            case (MovementMethod.CharacterForwardIsForward):
            {
                MoveInputVector = characterPlanarRotation * _moveInputVector;
                break;
            }

            default:
            {
                MoveInputVector = _moveInputVector;
                break;
            }
            }

            MethodOfMovement = playerInputs.MovementMethod;
            MethodOfRotation = playerInputs.RotationMethod;
        }
コード例 #23
0
ファイル: Pix.cs プロジェクト: paulrosenkranz/tesseract
        /// <summary>
        /// Creates a new image by rotating this image about it's centre.
        /// </summary>
        /// <remarks>
        /// Please note the following:
        /// <list type="bullet">
        /// <item>
        /// Rotation will bring in either white or black pixels, as specified by <see cref="fillColor" /> from
        /// the outside as required.
        /// </item>
        /// <item>Above 20 degrees, sampling rotation will be used if shear was requested.</item>
        /// <item>Colormaps are removed for rotation by area map and shear.</item>
        /// <item>
        /// The resulting image can be expanded so that no image pixels are lost. To invoke expansion,
        /// input the original width and height. For repeated rotation, use of the original width and heigh allows
        /// expansion to stop at the maximum required size which is a square of side = sqrt(w*w + h*h).
        /// </item>
        /// </list>
        /// <para>
        /// Please note there is an implicit assumption about RGB component ordering.
        /// </para>
        /// </remarks>
        /// <param name="angle">The angle to rotate by, in radians; clockwise is positive.</param>
        /// <param name="method">The rotation method to use.</param>
        /// <param name="fillColor">The fill color to use for pixels that are brought in from the outside.</param>
        /// <param name="width">The original width; use 0 to avoid embedding</param>
        /// <param name="height">The original height; use 0 to avoid embedding</param>
        /// <returns>The image rotated around it's centre.</returns>
        public Pix Rotate(float angle, RotationMethod method = RotationMethod.AreaMap, RotationFill fillColor = RotationFill.White, int? width = null, int? height = null)
        {
            if(width == null) width = this.Width;
            if(height == null) height = this.Height;
            var handle = Interop.LeptonicaApi.pixRotate(Handle, angle, method, fillColor, width.Value, height.Value);
            if(handle == IntPtr.Zero) throw new LeptonicaException("Failed to rotate image around it's centre.");

            return new Pix(handle);
        }
コード例 #24
0
        public static void CipherFileWithCardano(string filePath, RotationMethod rotationMethod, GridType gridType)
        {
            var fileDirectory = Path.GetDirectoryName(filePath);
            var plainText     = ReadTextFromFile(filePath);

            Console.WriteLine(plainText);

            var cipherObj = CardanoCipherGenerator.GenerateCardanoGrid(plainText.Length, rotationMethod, gridType);
            var cipher    = cipherObj.CipherGrid;

            cipher.PrintArray();

            var cipherLength = cipher.GetLength(0) * cipher.GetLength(1);

            var sub = cipherLength - plainText.Length;

            if (sub != 0)
            {
                plainText = plainText
                            .PadLeft(plainText.Length + (sub / 2), ' ')
                            .PadRight(plainText.Length + sub, ' ');
            }

            var plainTextQueue = new Queue <char>(plainText.ToArray());

            char [,] cipheredText = new char [cipher.GetLength(0), cipher.GetLength(1)];


            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < cipher.GetLength(0); j++)
                {
                    for (int n = 0; n < cipher.GetLength(1); n++)
                    {
                        if (cipher[j, n] == 1)
                        {
                            cipheredText[j, n] = plainTextQueue.Dequeue();
                        }
                    }
                }

                switch (rotationMethod)
                {
                case RotationMethod.StraightAngle:
                    if (gridType is GridType.Rect)
                    {
                        goto case RotationMethod.OpenAngle;
                    }
                    cipher.Rotate90Clockwise();
                    break;

                case RotationMethod.OpenAngle:
                    if (i % 2 == 0)
                    {
                        cipher.ReverseColumns();
                    }
                    else
                    {
                        cipher.ReverseRows();
                    }
                    break;
                }
            }

            cipheredText.PrintArray();

            string cipheredString = "";

            for (int j = 0; j < cipher.GetLength(0); j++)
            {
                for (int n = 0; n < cipher.GetLength(1); n++)
                {
                    cipheredString += cipheredText[j, n];
                }
            }

            Console.WriteLine(cipheredString);

            WriteCipherKeyToFile(fileDirectory + "key.bin", cipherObj);

            WriteTextToFile(fileDirectory + "ciphertext.txt", cipheredString);
        }