1
vote
1answer
41 views

Rotating a square rendered on a Bitmap

I'm writing a Software Renderer for fun/learning. Basically, it's just a giant array of integers which contain hexadecimal values (representing colour) that are rendered to the screen.... int ...
0
votes
1answer
68 views

Rotating a vector around a vector in 3D space

I am trying to rotate a moon around a planet (the planet is also rotating around an axis) but I am having trouble doing so. I tried to make the model move through space like so: @Override public ...
2
votes
2answers
214 views

How can I simplify this code to compute the shortest rotation between two angles?

The following code will find the shortest rotation (in radians) (from pi to -pi) that I need to apply to from to leave me with to. Scalar rotationBetween(Scalar from, Scalar to) { Scalar fromMod ...
0
votes
2answers
73 views

How can I find the difference between rotations represented as angles in [0, 360]?

What is the easiest way to find the difference between two 2D rotations/directions? I want to test if one rotation is within 10° of another. I would just subtract, but there are some problems ...
3
votes
3answers
155 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: M = R * S; // I need f and h such that ...
0
votes
0answers
70 views

rotating sprite with quaternion in scenegraph

I have been trying to set up a scenegraph in XNA, which I then use to draw sprites in the correct places. It uses matrix transformations to accomplish this. So far, I got position and scale working ...
1
vote
1answer
92 views

libgdx get rotated sprite coords points

I would like to get the position of each edge of a sprite when he has been rotated. I have no idea how to do it, I made a image to explain it. I would like to get the X and Y position of each Red ...
0
votes
1answer
54 views

Rotating image around a given point

Im trying to simulate shadows in a 2d RPG, So far I can make the shadows but i cant blit them properly, Im trying to rotate them according to where the "sun" is (just a position) I have looked at ...
-1
votes
1answer
117 views

lerp z rotation towards mousepointer

I am trying to get transform.rotation.z to chase the mouse pointer at a rotation speed. But I get a very weird results and can't figure out what I am doing wrong. var mp = Input.mousePosition; ...
1
vote
0answers
40 views

Calculating Friction due to rotation from ball bounce? [duplicate]

In this question asked by codemonkey, The rotation will depend upon: upon impact, on: Initial Speed of the ball hitting the surface (magnitude of ball velocity vector) Friction co-efficient of ball ...
4
votes
5answers
990 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 ...
0
votes
0answers
36 views

Sprite rotation algorithm [duplicate]

I'm making a game where you have to plot a function to hit certain objectives. I already made the plotting function and the animation to display a tiny missile that travels above the function. My ...
7
votes
3answers
370 views

Slerping rotation mirrors

I rotate my game character to watch at the target using the following code: transform.rotation = Quaternion.Slerp(startQuaternion, lookQuaternion, turningNormalizer*turningSpeed/10f) ...
0
votes
0answers
227 views

JavaScript 3D space ship rotation

I am working with a fairly low-level JavaScript 3D API (not Three.js) which uses euler angles for rotation. In most cases, euler angles work quite well for doing things like aligning buildings, ...
3
votes
0answers
231 views

Use quaterions to move the camera direction according to mouse movement

I am trying to use quaterions to move the camera direction vector in the following way. This code is perfectly working glm::quat temp1 = glm::normalize( glm::quat((GLfloat)( ...
-1
votes
1answer
405 views

Java moving image to where it is facing

I am trying to make an Asteroids type game. I searched and tried everything to move an image along its angle (as radiant). Using my knowledge of trigonometry I made the following calculation: x += ...
0
votes
0answers
104 views

Follow sinus with absolute value

I would like to make an arm follow the sinus of the ball. When I add an absolute value to the ball (on the y axis) to get a more realistic bounce, the ball is going 2 times faster. How could I ask ...
0
votes
1answer
150 views

Rotate 2d sprite towards pointer

I'm using Crafty.js and am trying to point a sprite towards the mouse pointer. I have a function for getting the degree between two points and I'm pretty sure it works mathematically (I have it under ...
0
votes
2answers
256 views

Is this Rotation Matrix correct?

I'm having heavly troubles with setting up a View Matrix and a Projection Matrix. It simply doesnt work. So I think my problem is related to my rotationMatrix function. I'm using this tutorial to ...
3
votes
1answer
241 views

Matrix represents same rotation with different euler angles

I have Transform component storing it's rotation as Quaternion. Transform has set/getEulerAngles (rotation order oy, ox, oz). I want to rotate object in any direction but while testing I get ...
2
votes
1answer
118 views

Rotation independent rotation

I came up with some cube rotating, but I could not make it smooth and easy to use because as the cube turned - the keys that handle the turning changed their purpose. Link to demo. The demo rotation ...
3
votes
3answers
1k views

Getting correct angles between Vector3s

I'm working on a project where you can draw lines between points. You select one point and drag the mouse onto another point and a line is drawn between them. The line itself is a 3d object which is ...
1
vote
5answers
1k views

how to rotate enemy to face player? [duplicate]

Okay so i havebeen rotating my enemy to face the player using float targetrotation = Math.Atan2(playerpos-enemypos); enemy.rotation = targetrotation; (<this line of code i want to change) This ...
4
votes
1answer
509 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 ...
3
votes
1answer
787 views

360+ degree rotation skips back to 0 degrees when using Math.Atan2(y, x)

I'm new to XNA and this is my first actual project, so forgive my noobness. I'm using jointAngle = System.Math.Atan2(RightStick.Y, RightStick.X); in order to set an angle of a joint (farseer) so ...
0
votes
1answer
222 views

Rotate/Translate object in local space

I am just trying to create a movementcontroller class for game entities. These class should transform the entity affected by the mouse and keyboard input. I am able to calculate the changed rotation ...
0
votes
1answer
377 views

Tilting towards turn direction (for a motorbike)

I have a motorbike which moves along based on a direction vector, I set its forward direction to the direction it's moving. What I'd like to also do with it is have the motorcycle tilt in the ...
1
vote
1answer
196 views

Camera lookAt target changes when rotating parent node

have the following issue.I have a camera with lookAt method which works fine.I have a parent node to which I parent the camera.If I rotate the parent node while keeping the camera lookAt the target , ...
1
vote
2answers
465 views

Confusion about Rotation matrices from Euler Angles

I am trying to learn more about Euler Angles so as to help myself in understanding how I can control my camera better in the game. I came across the following formula that converts Euler Angles to ...
1
vote
1answer
508 views

How to get a point to the left/right of a vector

I have a position vector of a point in space and a quaternion for it's rotation. What i'm trying to calculate is a point too the left and a point to the right. I have the position and ...
3
votes
2answers
442 views

3D rotation matrices deform object while rotating

I'm writing a small 3D renderer (using an orthographic projection right now). I've run into some trouble with my 3D rotation matrices. They seem to squeeze my 3D object (a box primitive) at certain ...
2
votes
2answers
1k views

Rotating a child shape relative to its parent's orientation

When rotating a shape using a quaternion value I also wish rotate its child shape. The parent and child shapes both start with different orientations but their relative orientations should always be ...
6
votes
1answer
292 views

How can I get a 2D texture to rotate like a compass in XNA?

I'm working on a small maze puzzle game and I'm trying to add a compass to make it somewhat easier for the player to find their way around the maze. The problem is: I'm using XNA's draw method to ...
2
votes
2answers
3k views

Rotate sphere in Javascript / three.js while moving along x/z plane

I have a sphere/ball in three.js which I want to "roll" around on the x/z plane. For the z axis I could simply do this no matter what the current x and y rotation is: sphere.roll_z = ...
3
votes
2answers
474 views

How to derive euler angles from matrix or quaternion?

Currently working on steering behavior for my AI and just hit a little mathematical bump. I'm in the process of writing an align function, which basically tries to match the agent's orientation with ...
8
votes
2answers
349 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 ...
1
vote
3answers
328 views

Inverting matrix then decomposing gives different quaternion than decomposing then inverting the quat

I'm getting different signs when I convert a matrix to quaternion and invert that, versus when I invert a matrix and then get the quaternion from it: Quaternion a = Quaternion.Invert(getRotation(m)); ...
1
vote
2answers
239 views

How can I determine the direction of turn?

I want a function that gives me the turn direction for my object (1 or -1) I have two angles 1 - current rotation(A) 0 <= A <= 360 2 - target rotation(B) 0 <= B <= 360 int turnSide ...
3
votes
1answer
428 views

Smoothing rotation

I've spent the last three days trying to work out how to rotate a sprite smoothly depending on the velocity.x value of the sprite. I'm using this: float Proportion = 9.5; float maxDiff = 200; float ...
0
votes
1answer
803 views

Camera Rotation (for mouse look) with LookAt does not work as expected (Local/Global)

My code for rotating my 3D fps camera isn't working as expected. I expect that the X-axis does rotate with the Y-axis, but it ain't so. I made some pictures to explain it better, I think its doing ...
9
votes
2answers
4k 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, ...
1
vote
2answers
2k views

How can I rotate a sphere in response to mouse movement?

I'm using jMonkeyEngine to develop a game. I'm good at scripting, but math usually goes over my head. I tried the Wiki page for Quaternion, but I was far too confused to figure this out myself :P My ...
2
votes
1answer
721 views

Allegro 5 Mouse Look

I found good tutorial on how to do mouse look for 2D game here: http://www.atburrow.com/2010/03/08/objects-facing-the-cursor/ My code looks like this: w = (double)mouse_x - (double)pos_x; h = ...
1
vote
0answers
672 views

Rotation deforming mesh (Opengl ES 2.0)

I'm trying to render a rotating cube on Opengl ES 2.0, using some math classes I wrote (based on a lot of online and offline info) for quaternions, matrixes and the like. As far as I know all the math ...
6
votes
2answers
850 views

What is eigenvalue decomposition and why would it be useful in games?

In various math libraries developed for game engines, I see 2x2 and 3x3 square matrices having this function (along with some helper functions). I tried to find information regarding it but did not ...
4
votes
4answers
5k 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 Eular Angles and I need to perform smooth interpolation between them. The best way is converting them ...