Questions tagged [rotation]

Rotation is the circular movement of an object around a specific axis.

Filter by
Sorted by
Tagged with
64 votes
2 answers
30k views

I'm rotating an object on two axes, so why does it keep twisting around the third axis?

I see questions come up quite often that have this underlying issue, but they're all caught up in the particulars of a given feature or tool. Here's an attempt to create a canonical answer we can ...
DMGregory's user avatar
  • 134k
36 votes
2 answers
6k views

Calculating the rotational force of a 2D sprite

I am wondering if someone has an elegant way of calculating the following scenario. I have an object of (n) number of squares, random shapes, but we will pretend they are all rectangles. We are ...
jgallant's user avatar
  • 8,414
26 votes
8 answers
79k views

How to calculate corner positions/marks of a rotated/tilted rectangle?

I've got two elements, a 2D point and a rectangular area. The point represents the middle of that area. I also know the width and height of that area. And the area is tilted by 40° relative to the ...
Stacky's user avatar
  • 395
26 votes
4 answers
11k views

How can I rotate an object based on another's offset to it?

I have a 3D model of a turret that con rotate around the Y-axis. This turret has a cannon that is significantly off the center of the object. I want the cannon, not the turret, to aim at a specified ...
Franconstein's user avatar
26 votes
2 answers
6k views

Using Quaternions: What can I do with them? (without the maths)

I am a Game Developer and did not study Mathematics. So I only want to use Quaternions as a tool. And to be able to work with 3D rotation, it's necessary to use Quaternions (Or Matrixes, but let's ...
OC_RaizW's user avatar
  • 1,450
25 votes
6 answers
7k views

How to make sure spinning objects hit a target with the right end?

I'm working on a throwing knife type weapon where a player free aims and then throws a knife. The knife spins through the air and on collision stops spinning and parents itself to the object it ...
FrontEnd's user avatar
  • 1,697
24 votes
4 answers
30k views

How to rotate blocks in tetris

I have a gameboard grid which is 20 rows high and 10 columns wide with the origin (0,0) being in the top left hand corner. I have a tetrimino in play, which is composed of four blocks. I have the x,y ...
user avatar
19 votes
5 answers
57k views

How can I orbit a camera about it's target point?

I'm drawing a scene where the camera freely moves about the universe. The camera class keeps track of the view (or look at) point, the position of the camera, and the up vector. These vectors/points ...
Luke's user avatar
  • 355
18 votes
4 answers
11k views

How to keep my Quaternion-using FPS camera from tilting and messing up?

I am using an FPS-like camera, and it uses quaternions. But, whenever I try looking up and then sideways, it tilts, and sometimes it can turn upside down. How can I fix this?
Aeodyn's user avatar
  • 371
16 votes
2 answers
15k views

How can I rotate about an arbitrary point in 3D (instead of the origin)?

I have some models that I want to rotate using quaternions in the normal manner, except instead of rotation about the origin, I want it to be offset slightly. I know that you don't say, in 3d space, ...
notlesh's user avatar
  • 3,877
16 votes
3 answers
38k views

How can I rotate pixel art sprites without the aesthetics getting ruined?

I'm right now in front of a huge "Game Design" question. I'm making a pixel-art-ish game and using bilinear interpolation could solve lots of animation-issues. On the other hand, its not a "pixel-game"...
OC_RaizW's user avatar
  • 1,450
16 votes
6 answers
22k views

How to rotate an object around world aligned axes?

I have a Vector3 which has an euler angle for each axis. Usually, when I want to create a rotation matrix I will use functions such as D3DXMatrixRotationX passing the respective angle from my ...
Syntac_'s user avatar
  • 1,001
15 votes
4 answers
37k views

GLM: Euler Angles to Quaternion

I hope you know GL Mathematics (GLM) because I've got a problem, I can not break: I have a set of Euler Angles and I need to perform smooth interpolation between them. The best way is converting them ...
Bunkai.Satori's user avatar
14 votes
3 answers
25k views

How do I make an entity move in a direction?

I have an Entity instance which is updated every game tick. Let's just assume that entity moves forward constantly. I'd like to be able to give the entity's angle ...
Shaun Wild's user avatar
13 votes
2 answers
26k views

How can I move a sprite in the direction it is facing?

I'm using Java/Slick 2D. I'm trying to use the mouse to rotate the sprite and the arrow keys to move the sprite. I can get the sprite to rotate no problem, but I cannot get it to move in the direction ...
rphello101's user avatar
13 votes
2 answers
12k views

How is the gimbal locked problem solved using accumulative matrix transformations

I am reading the online "Learning Modern 3D Graphics Programming" book by Jason L. McKesson As of now, I am up to the gimbal lock problem and how to solve it using quaternions. However right here, ...
Luke San Antonio Bialecki's user avatar
13 votes
2 answers
6k views

Arbitrary Rotation about a Sphere

I'm coding a mechanic which allows a user to move around the surface of a sphere. The position on the sphere is currently stored as theta and ...
azz's user avatar
  • 233
12 votes
2 answers
4k views

How to make my 2D character stand normally on slope?

I've got this character in Unity3D (2D Mode)... in a a slope which looks like this, But I want the character to stand along the red line..Like below How can I make it in Unity3d? I've got this ...
jamius19's user avatar
  • 307
12 votes
3 answers
8k views

Rotate object around fixed axis

I am trying to let the user of my app rotate a 3D object drawn in the center of the screen by dragging their finger on screen. A horizontal movement on screen means rotation around a fixed Y axis, and ...
Christopher Perry's user avatar
11 votes
2 answers
11k views

How do I rotate a structure of hexagonal tiles on a hexagonal grid?

My 2D isometric game uses a hexagonal grid map. In reference to the image below, how do I rotate the light blue hexagon structures by 60 degrees around the pink hexagons? EDIT: Main hex is (0,0). ...
ruzsoo's user avatar
  • 111
10 votes
1 answer
2k views

Xbox thumbstick used to rotate sprite, basic formula makes it "stick" or feel "sticky" at 90 degree intervals! How do you get smooth rotation?

I am using a very basic formula to calculate what angle my sprite (spaceship for example) should be facing based on the Xbox controller thumbstick i.e. you use the thumbstick to rotate the ship. In ...
Hugh's user avatar
  • 309
10 votes
2 answers
16k views

How to avoid gimbal lock

I am trying to write code with rotates an object. I implemented it as: Rotation about X-axis is given by the amount of change in y coordinates of a mouse and Rotation about Y-axis is given by the ...
singingsingh's user avatar
10 votes
1 answer
36k views

How to calculate a 3x3 rotation matrix from 2 direction vectors?

I've got 2 direction vectors, for the X axis and the Y axis of the object. How do I calculate the rotation matrix of the object using these?
Robin Rodricks's user avatar
10 votes
3 answers
32k views

How to rotate an image on an HTML5 canvas, without rotating the whole canvas?

I want to rotate single sprites on the canvas without rotating the whole canvas. I also don't want to create a new canvas for each object I have. Also, it would be interesting to know which solution ...
JustGoscha's user avatar
10 votes
1 answer
17k views

Angle between two points

I have a character who walks to random points in my room in Unity. The problem is he always faces one direction, I want to write in C# a piece of code that will get the direction the character is ...
Darren's user avatar
  • 151
10 votes
2 answers
14k views

Rotate billboard towards camera

I'm trying to create a particle system in OpenGL, and as such I need to use billboards. I need these billboards to face the camera at all times. The tutorials I've been following only rotated the ...
Yattabyte's user avatar
  • 1,013
9 votes
2 answers
3k views

How do I simulate a swinging pendulum?

I want to simulate a rope with a weight attached, swinging back and forth like a pendulum. Any actual physics is overkill; it's just endlessly repeating the same motion. JQuery has a the "swing" ease ...
mjanisz1's user avatar
  • 247
9 votes
1 answer
14k views

Unity: transform.LookAt(target) not "looking at" target?

I have been troubleshooting a prefab for several hours and am out of ideas. It concerns a method that I thought I was comfortable with, transform.LookAt(target). I have this prefab: As you can see, ...
hatinacat2000's user avatar
9 votes
2 answers
1k views

Render 3d object to 2d surface (embedded system)

i am working on an embedded system of a sort, and in some free time i would like to test its drawing capabilities. System in question is ARM Cortex M3 microcontroller attached to EasyMX Stellaris ...
Martin Berger's user avatar
9 votes
4 answers
465 views

Keeping rotation between two objects

In my XNA game I have two objects that collide. When the first object collides with the other it is able to latch on to it and move it about the world. I am having a problem with the math here (Math ...
user99's user avatar
  • 91
9 votes
3 answers
666 views

Slerping rotation mirrors

I rotate my game character to watch at the target using the following code: ...
Esa's user avatar
  • 1,501
9 votes
3 answers
1k views

Can I use quaternions to control an helicopter?

I'm trying to make a simplified helicopter (for the moment, it's a cube) simulation in 3D and I'm having some problems with rotation. An helicopter can rotate along the three axes : rotate on itself ...
subb's user avatar
  • 285
9 votes
2 answers
6k views

How to implement friction in a physics engine based on "Advanced Character Physics"

I have implemented a physics engine based on the concepts in the classic text Advanced Character Physics by Thomas Jakobsen. Friction is only discussed very briefly in the article and Jakobsen himself ...
paldepind's user avatar
  • 627
8 votes
2 answers
2k views

Rotate a vector

I want my first-person camera to smoothly change its viewing direction from direction d1 to direction d2. The latter direction is indicated by a target position t2. So far I have implemented a ...
marc wellman's user avatar
8 votes
1 answer
8k views

Why is my sprite displayed offset from its Box2D body?

I found out about this using a debug renderer. When the game starts, everything is in order. But when a collision happens, the sprite's rotation is way larger than its body. The sprite and body match ...
Tae-Sung Shin's user avatar
8 votes
3 answers
2k views

Routes on a sphere surface - Find geodesic?

I'm working with some friends on a browser based game where people can move on a 2D map. It's been almost 7 years and still people play this game so we are thinking of a way to give them something new....
CaNNaDaRk's user avatar
  • 183
8 votes
2 answers
15k views

How to rotate camera centered around the camera's position?

Currently I am using gluLook at like so: ...
tnutty's user avatar
  • 81
8 votes
1 answer
1k views

How To Approach 360 Degree Snake

I've recently gotten into XNA and must say I love it. As sort of a hello world game I decided to create the classic game "Snake". The 90 degree version was very simple and easy to implement. But as I ...
Austin Brunkhorst's user avatar
8 votes
2 answers
4k views

Calculating a quaternion so a bone points in a specified direction

In an attempt to solve this question, I decided to figure out the absolute (world space) directions of each joint in the source pose (as normalized unit vectors), and then rotate the joints of the ...
Robert Fraser's user avatar
8 votes
1 answer
358 views

How can I keep the clicked point under the mouse when rotating? (GLM)

I have a spherical mesh of radius 1, centered at (0,0,0) in world coordinates. I want to rotate the sphere so that the clicked point remains under the mouse at all times. However, I cannot find an ...
Jubei's user avatar
  • 191
7 votes
3 answers
4k views

Tetris : Effective rotation

I rotate each piece by rotation formula. More detail, because rotation angle is 90 so : xNew = y; yNew = -x; But my method has met two problems : 1) Out of ...
hqt's user avatar
  • 309
7 votes
1 answer
2k views

Orbiting multiple objects evenly around a changing radius

I have multiple objects (circles) and I want to place them in a circle, with even distance between each one, and have them orbit the center of the screen. If I remove one object, I want the orbit ...
Nicholas's user avatar
  • 431
7 votes
1 answer
5k views

Libgdx sprite rotation (image quality)

This one is probably really simple but I didn't find a solution. I'm trying to create a widget (speedometer) with libgdx. For the arrows I'm using the setRotation()...
dzonatan's user avatar
  • 185
7 votes
1 answer
2k views

Calculate gears rotation for a realtime simulation

I'm trying to do a game with real time simulations of gears. There is a big Gear with inside a smaller gear. I managed to draw gears with different diameters but equal size teeth, but if i try to move ...
nkint's user avatar
  • 961
7 votes
1 answer
2k views

Turning a sprite such that it rotates in the direction that's most efficient

I have a sprite that moves from waypoint to waypoint. It turns to face its velocity vector, but not instantly (there's a rotation speed). The problem I'm having is, from one direction to another, the ...
user avatar
7 votes
2 answers
3k views

Matrix rotation wrong orientation LibGDX

I'm having a problem with matrix rotation in libgdx. I rotate it using the method matrix.rotate(Vector3 axis, float angle) but the rotation happens in the model orientation and I need it happens in ...
glz's user avatar
  • 71
6 votes
2 answers
29k views

Rotating an object with quaternion

I have a question in regards to using quaternions for the rotation of my graphics object. I have a Transform class which has the following constructor with default ...
Kakalokia's user avatar
  • 243
6 votes
1 answer
8k views

How do I rotate a sprite so that it is 'pointing' in the direction it is moving?

I have a sprite, e.g a missile, heading in a certain direction (using a velocity vector). How do I figure out its how much to rotate it so that it gets drawn 'pointing' in the direction it is heading?...
Ken's user avatar
  • 6,116
6 votes
3 answers
6k views

How do I disassemble a 3x3 transformation matrix into rotation and scaling matrices?

I have a transformation matrix that rotates and scales. Is there any easy way to disassemble it into the original rotation and scaling matrices? For instance: ...
AturSams's user avatar
  • 10.5k
6 votes
3 answers
1k views

Why is my model's scale changing after rotating it?

I have just started a simple flight simulator and have implemented Roll and pitch. In the beginning, testing went very well; however, after about 15-20 seconds of constantly moving the thumbsticks in ...
Justin Self's user avatar

1
2 3 4 5
24