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)); }
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(); }
private static void Lab4() { ReadingService.ReadLab4(); var A = new matrix(Lab4Matrix); var answer = new RotationMethod(A).GetAnswer(); Console.WriteLine("U matrix:"); answer.Print(); }
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(); }
// 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(); } }
protected override void HandleRotateBody(RotationMethod method) { if (References.NetworkIdentity.hasAuthority == false) { return; } else { base.HandleRotateBody(method); } }
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); }
protected virtual void HandleRotateBody(RotationMethod method) { switch (method) { case RotationMethod.TowardMoveInput: HandleRotateTowardMoveInput(); break; case RotationMethod.TowardAim: HandleRotateTowardAim(); break; case RotationMethod.TowardVelocity: HandleRotateTowardVelocity(); break; } }
/// <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)); }
/// <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)); }
/// <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); }
// 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(); } }
IntPtr pixRotate(IntPtr pixs, float angle, RotationMethod type, RotationFill fillColor, int width, int heigh);
// 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(); } }
public static extern IntPtr pixRotate(HandleRef pixs, float angle, RotationMethod type, RotationFill fillColor, int width, int heigh);
/// <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 }); }
internal static extern IntPtr pixRotate(HandleRef pixs, float angle, RotationMethod type, RotationFill fillColor, int width, int heigh);
public IRotation Get(RotationMethod rotation) => rotation switch {
void Start() { HandRotationMethod = GetComponent <RotationMethod>(); }
public virtual IRotation Get(RotationMethod model) => _factory.Get(model);
/// <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; }
/// <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); }
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); }