rotation

How to detect screen rotation on Android in Kivy?

♀尐吖头ヾ 提交于 2021-02-20 17:54:26
问题 I have been searching for a Kivy solution to capture the Android device rotation from one orientation to another. I have tried both of the window methods below but neither executes the on_rotate or rotate_screen routines when I rotate the device. I see there is an onConfigurationChanged event in java but I can't find the same event handling for Kivy. Window.on_rotate(self.on_rotate) Window.bind(on_rotate=self.rotate_screen) What I do get in the logcat is the following messages indicating the

How to detect screen rotation on Android in Kivy?

ぃ、小莉子 提交于 2021-02-20 17:53:23
问题 I have been searching for a Kivy solution to capture the Android device rotation from one orientation to another. I have tried both of the window methods below but neither executes the on_rotate or rotate_screen routines when I rotate the device. I see there is an onConfigurationChanged event in java but I can't find the same event handling for Kivy. Window.on_rotate(self.on_rotate) Window.bind(on_rotate=self.rotate_screen) What I do get in the logcat is the following messages indicating the

How do you rotate an array 90 degrees without using a storage array?

流过昼夜 提交于 2021-02-19 06:16:11
问题 I was instructed not to use a storage array to complete this task. Basically, we have to create a function that rotates the contents of a 2d array 90 degrees. So if I start off with this array: int[][] array = {{1,2,3}, {4,5,6}, {7,8,9}}; The function should return an array like this: {{7,4,1}, {8,5,2}, {9,6,3}} Again we are not allowed to use a created array within the function for storage. Is it even possible to accomplish this without a storage array? 回答1: You can rotate/transpose the

Get angle between two 2d lines. (With respect to the direction of the lines)

自闭症网瘾萝莉.ら 提交于 2021-02-19 05:28:00
问题 I want to get the angle between two lines with respect to direction of the line. A normal dot product of the 2 vectors of the lines always returns the lowest angle between the two lines, which is not what I'm looking for. Example image: Blue lines: The lines I have Red lines: indication of the direction Green lines: failed attempt at a curving line that indicates the direction of the rotation I want. p0~p3: the x, y coordinates of the points of the lines. a: The angle I am looking to get. I

Get angle between two 2d lines. (With respect to the direction of the lines)

随声附和 提交于 2021-02-19 05:25:26
问题 I want to get the angle between two lines with respect to direction of the line. A normal dot product of the 2 vectors of the lines always returns the lowest angle between the two lines, which is not what I'm looking for. Example image: Blue lines: The lines I have Red lines: indication of the direction Green lines: failed attempt at a curving line that indicates the direction of the rotation I want. p0~p3: the x, y coordinates of the points of the lines. a: The angle I am looking to get. I

rotate Z axis on 2d image's matrix in shader

ぐ巨炮叔叔 提交于 2021-02-19 04:41:28
问题 I'm trying to rotate a 2d image's matrix inside the vertex shader. I want the 2d image to rotate around what I think would be the z axis. However The closes I've ever gotten is: Here is my matrix inside my shader that I apply translation and scaling on: mat4 worldPosTrans = mat4(vec4(scale.x * cos(rotateZ), 0, 0, 0), vec4(0, scale.y, 0, 0), vec4(0, 0, scale.z, 0), vec4(translation, 1)); This is a slightly changed version from something that was supposed to rotate everything: mat4

How can I flip/rotate the label in C#/Windows Forms?

断了今生、忘了曾经 提交于 2021-02-16 13:09:27
问题 How can I flip/rotate the label in C# Windows Forms? I set the background image to my label. At every time interval it moves three pixels to the right side. When it reaches the form end position I need the label to be flipped and turned back. I have tried the following way, but I didn't get the solution. private void timer1_Tick(object sender, EventArgs e){ if (label2.Location.X < this.Width) label2.Location = new Point(label2.Location.X + incr, label2.Location.Y); else { incr = -2; label2

Moving forward after angle change. Pygame

吃可爱长大的小学妹 提交于 2021-02-12 11:41:25
问题 I've been working on this project about tanks (based on game Tank Trouble) and I'm wondering how I can move forward after I change angle of the sprite. Also if you know how I can make my bullets ricochet from the walls. I will really appreciate any help given. Thank you! Here is my tank and bullet: Here is code of the game: import sys import pygame class Game: def __init__(self): self.run = True self.screen_width = 1060 self.screen_height = 798 self.image = pygame.image.load("sprites

How do you rotate a bitmap an arbitrary number of degrees?

主宰稳场 提交于 2021-02-11 13:47:35
问题 I have a bitmap: Bitmap UnitImageBMP And I need to rotate it an arbitrary number of degrees. How do I do this? The RotateFlip method will only rotate in increments of 90 degrees. 回答1: I did some searching for you and found this: public static Bitmap RotateImage(Bitmap b, float angle) { //create a new empty bitmap to hold rotated image Bitmap returnBitmap = new Bitmap(b.Width, b.Height); //make a graphics object from the empty bitmap using(Graphics g = Graphics.FromImage(returnBitmap)) { /

How do you rotate a bitmap an arbitrary number of degrees?

三世轮回 提交于 2021-02-11 13:44:37
问题 I have a bitmap: Bitmap UnitImageBMP And I need to rotate it an arbitrary number of degrees. How do I do this? The RotateFlip method will only rotate in increments of 90 degrees. 回答1: I did some searching for you and found this: public static Bitmap RotateImage(Bitmap b, float angle) { //create a new empty bitmap to hold rotated image Bitmap returnBitmap = new Bitmap(b.Width, b.Height); //make a graphics object from the empty bitmap using(Graphics g = Graphics.FromImage(returnBitmap)) { /