Questions tagged [matrix]

A 2D array of numbers, symbols or expressions, arranged in rows and columns. Each row must have the same number of columns. The numbers, symbols or expressions themselves are called elements or entries.

52 questions
13k 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, ...
50k views

Why do we move the world instead of the camera?

I heard that in an OpenGL game what we do to let the player move is not to move the camera but to move the whole world around. For example here is an extract of this tutorial: OpenGL View matrix ...
40k views

Transform Matrix multiplication order

I am experiencing difficulties trying to figure out the correct multiplication order for a final transform matrix. I always get either strange movement or distorted geometry. My current model is ...
17k 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 ...
106k views

What is the correct order to multiply scale, rotation and translation matrices for a proper world matrix?

Assume DirectX as the platform, if that is important. (Pretty sure it isn't) Assuming I have a proper scale, rotation and translation matrix, in what order do I multiply them to result in a proper ...
20k views

Why do we use 4x4 matrices to transform things in 3D?

To translate a vector by 10 unit in the X direction, why do we have to use a matrix? We can just add 10 to the mat[0][0], and we got the same result too.
10k views

Combining rotation,scaling around a pivot with translation into a matrix

In short: I need to combine rotation (in the form of a quaternion), scaling around a pivot point along with translation into a transformation matrix. The long: I am trying to implement a proprietary ...
4k views

Matrix for 2D perspective

I'm trying to determine whether what I'm attempting to achieve is even possible mathematically. I'm obviously not a seasoned game developer so I'm having trouble even coming up with the terminology to ...
13k views

Transform coordinates from 3d to 2d without matrix or built in methods

Not to long ago i started to create a small 3D engine in javascript to combine this with an html5 canvas. One of the issues I run into is how can you transform 3d to 2d coords. Since I cannot use ...
375 views

How attach a model with another model on a specific bone?

I meet a difficulty attached to a model to another model on a "bone" accurate. I searched several forums but no result. I saw that many people have asked the same question but no real result see no ...
2k views

Moving a rotated model in XNA

This seems like a simple problem with an equally simple solution that is invisible to me. I have a model that spawns at the origin and looks at my player model wherever it goes. I would like it to ...
196 views

Do matrix manipulations for 3D graphics ever produce singular matrices?

A singular matrix is a matrix that cannot be inverted. The vecmath library, for example, throws a SingularMatrixException if you try to invert a singular matrix. I think I understand what singular ...
627 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: ...
365 views

Keep Mini map static after rotating / zooming with camera

Hi I am making a 2D game, where the Camera is able to rotate / zoom in or out on the camera focus (the player usually). However my game also contains a mini-map, and so far whenever I have to rotate ...
7k views

Staggered Isometric Map: Calculate map coordinates for point on screen

I know there are already a lot of resources about this, but I haven't found one that matches my coordinate system and I'm having massive trouble adjusting any of those solutions to my needs. What I ...
4k views

Can someone explain the (reasons for the) implications of colum vs row major in multiplication/concatenation?

I am trying to learn how to construct view and projection matrices, and keep reaching difficulties in my implementation owing to my confusion about the two standards for matrices. I know how to ...
2k views

Downprojecting an imaginary 4D mesh to the screen

As a mental exercise, I'm trying to imagine projecting an arbitrary 4D mesh onto the screen (2D). I'm guessing a single 4D triangle would still consist of only 3 points, however each of those 3 ...
29k views

How does gluLookAt work?

From my understanding, gluLookAt( eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z ); is equivalent to: <...
3k views

Should the modelview and projection matrices be calculated in the shader or on the CPU?

At minimum I would have a camera with rotation and world position; projections parameters such as angle of view and perspective vs. orthographic; and meshes with scale, angle, and world position. ...
8k views

View matrix in opengl

Sorry for my clumsy question. But I don't know where I am wrong at creating view matrix. I have the following code: ...
17k views

How to get translation from view matrix

How can I retrieve the camera's world-space position from its view matrix? The only answers I've seen to this question suggest the translation is in the last row/col but this wouldn't work since the ...
3k views

Why do we refer to a “model view” matrix and not a “viewprojection” matrix?

Why there is a model-view matrix, but not a view-projection matrix? A view-projection matrix would make much more sense to me, since every entity in the scene has his own position and therefore its ...
1k views

How to move an object up and down like a wave?

I am trying to move my object up and down using cos and sin, but I have problem understanding how does the ...
2k views

Translate along local axis

I have an object with a position matrix and a rotation matrix (derived from a quaternion, but I digress). I'm able to translate this object along world-relative vectors, but I'm trying to figure out ...
1k views

How can I attach a model to the bone of another model?

I am trying to attach one animated model to one of the bones of another animated model in an XNA game. I've found a few questions/forum posts/articles online which explain how to attach a weapon ...
842 views

importing animations in Blender, weird rotations/locations

This is for the Blender 2.6 API. There are two problems: 1. When I import a single animation frame from my animation file to Blender, all bones look fine. But when I import multiple (all of the ...
3k views

The correct way to transform a ray with a matrix?

Playing with XNA Triangle Picking Sample I found out that it does not work well if you scale the world matrix of the objects you want to pick. When I dug into the implementation I found this comment ...
475 views

Transformation matrix that maps a window

I'm currently learning OpenGL at uni, and they give us questions to help us learn (these are not worth anything), however I'm stuck on this one question and would have to travel over an hour and a ...
2k views

XNA Camera 2D confusion

I have followed the tutorial at http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/ to implement my 2D camera and everything works just fine. However this leaves me confused. ...
2k views

Fastest way to neutralize scale in the transform matrix?

Let's assume we have 4x4 3D transformation matrix, that is the result of scale, rotation, and translation transforms. How to set its scale to (1,1,1) in the fastest way? Assume also that the matrix is ...
1k views

Transformation order when dealing with Meshes

I have created a player model out of primitive types. To do this I have created a Model class and Component (mesh) class. Each model consists of one or more components my problems start when you have ...
113 views

How to compute a transformation matrix that describes each position and rotation on a sphere?

I am having an issue constructing my transformation matrices, for this sphere problem. I know the 3d coordinate of the center, and the radius of, the sphere. Since I know the radius and center of ...
965 views

How to modify normal vectors with a tranformation matrix

Transformation is quite simple when it comes to Position or Color of the vertex, for Position just multiply matrix * vector and for color just don't do anything, but my question now is: How to handle ...
374 views

3d world vertex translation to go to 2d screen coords

My technical english is a little rusty so to avoid misunderstands please be patient with me :) I will try to be brief and clear Situation: - I have a 2d sprite character on the screen - I've just ...
2k views

How would you design a transformation matrix to project absolute coordinates to any orthographic projection desired?

I am attempting to make an RTS based on AoE II HD Edition. I want to have ease of control by designing a transformation matrix given any style of projection I want. This is a good example of what I ...
1k views

Is there a common word that encompasses handling of position, rotation, and scale together?

I'm looking for a name for my class that manipulates 4x4 matrices that handle position, rotation, and scale. Is there a common word that encompasses all three? (I'm splitting the matrix math into its ...
819 views

Portal Projection

Ok ok I admit, I'm bored and toying with a portal script like the one on steam. I've figured out the following: relative positioning of the mirrored cameras render to texture for the portal (the ...
509 views

How to linearly transform vertices for large coordinate systems

Alright, so I'm working on a space game and well, I want it to have a lot of space! So I need a large coordinate system and for my rendering pipeline to not suffer from "vertex jittering" due to ...
5k views

Tetris - Rotations using Linear Algebra (Rotation Matrices)

I'm making Tetris in Java and am at the point of rotations... Originally I was hardcoding each rotation: ...
2k 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 ...
390 views

what is the very last element of a 4x4 transformation matrix for? [duplicate]

while its a similar value to its neighbour - Z translation (and I wont say if thats above or to the left for fear of sparking a religious war!) and it only seems to change when the Z translation value ...
2k views

How do I calculate an offset from an Object based on the Objects Rotation rather than the World Space

I have a Matrix of a player & I want to create a second location a set distance away from the first location but I want the second matrix to be set a set distance based on the rotation of the ...
2k views

Restoring projection matrix

I am learning to use FBOs and one of the things that I need to do when rendering something onto user defined FBO, I have to setup the projection, modelview and viewport for it. Once I am done ...
964 views

2D HLSL World position

I'm trying to get world position from my vertex shader to my pixel shader so that I can disable the shader once a preset X coordinate has been passed (no shading once I'm over X). Getting the screen ...
2k views

Translating local to global coordinates in ARToolkit / OpenGL

Ok, so I've tried reading over the other questions and something's just not clicking for me. I am working on an augmented reality application using ARToolkit, however it should just be straight ...
2k views

Matrix rotation of a rectangle to “face” a given point in 2d

Suppose you have a rectangle centered at point (0, 0) and now I want to rotate it such that it is facing the point (100, 100), how would I do this purely with matrix math? To give some more specifics ...
128 views

Why does a translation matrix need extra row?

Following recommendation of this answer I've recently read the series of articles of Wolfire about linear algebra. I'm somewhat familiar with matrices and I came to a conclusion that vector and a ...
102 views

What is more efficient: Using matrix translation to move a character, or using a vector/scalar?

In 2D or 3D, matrix transformations are used for rotation, scaling, and sheering. However, when it comes to movement, should I go out of my way to use and implement scalar/vector movement, or just ...