# 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.

503 questions
239 views

### Problem Rendering a Wireframe Cube and Grid with DirectX 11

I am trying to draw a 3D Wireframe (just the lines that connect each vertex) Cube and a 10x10 grid with D3D11. So far, this is my code ...
88 views

### How Matrix4 represents an object in space and matrix lore

I have been following some tutorial's on how Matrix maths works, with adding, dividing, scaling, etc, but I am struggling to understand how the 4x4 matrix represents an object's position in space. ...
555 views

### Translation Matrix not working properly

Hello, I get this result when i try to scale and then translate a vec4 in my shader. I created a mat4x4 class on my own and some functions wich return some matrices for me, everything works, but not ...
96 views

### Optimizing black and white matrix block drawing

Disclaimer: I am uncertain if this is the best place to post this question, so please advise me of how I can best find the answer if I am doing something wrong. I am asking this question because I am ...
75 views

### How to convert -1 to 1 coordinate back to screen coordinates?

Here is a question in which Questioner asks how to convert world coordinates to 1 to -1 coordinates like Opengl, I want to know how to do that in reverse, that given a coordinates between 1 and -1 (...
311 views

### js canvas tiled map - for loop, while, or matrix

I am making a top-down view tiled map in canvas, where player is always in the middle of the screen, and map scrolls depending on where you go, like in moba games. I also want it to loop infinitely in ...
275 views

### Get the difference between 2 matrices

Hi I'm using C# and MonoGame, and have the world matrices of 2 objects. I need to get the difference between them, so I can ...
274 views

### DX11 Camera not working properly

I'm currently trying to implement a ArcBall Camera which should fly around a given XMFLOAT3 position stored in a cb with a spezified distance to the position. I used the code from Allen Sherrod for ...
2k views

### Extract a rotation matrix given a camera direction (vector) and a up vector for the camera?

I am having some issues constructing a rotation matrix from a camera direction vector. The Up vector is computed from the camera direction as such: ...
101 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 ...
1k 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 ...
89 views

### How to spin a 2D quad in place using only matrices?

In short, I have a textured 2D quad (a sprite). I would like to rotate/spin it about the z-axis (coming out of the screen) using nothing but matrices. If I do the following to a transform with scale ...
349 views

### Control frustum near and far clip plane sizes in a Projection Matrix

I'm trying to achieve a dolly zoom effect. My first try was the obvious one, the original "zoom in & dolly out" technique, which works nicely. Except that there are cases which this is not ...
660 views

### OpenGL perspective matrix far plane

The near plane clips at exactly the value I set just fine but instead of clipping at 1000 the far plane clips at 1. Here is the code for the projection matrix: ...
85 views

### What are projection independent ways of determining whether a normal is facing the viewer?

A position v and normal n are given in world coordinates. Also there is a view matrix V for ...
124 views

### Projection Matrix Breaks My Rectangle

This is my vertex shader, shown below. ...
2k views

### How do you build a rotation matrix from a normalized vector?

I'm trying to find the correct way to build a rotation matrix from a unit vector. I have two arbitrary points in space (p1 and p2), and I'm trying to create the vertices for a rectangle to span ...
751 views

### OpenGL Arc-Ball Camera Yaw Pitch GLM::Rotate

I'm currently working on a small Voxel-Editor Project. In the editor, I plan on using an Arc-Ball camera which rotate around the model. My camera is currently working but in an odd way. I can't seem ...
1k views

### Convert transform from world to local space

I have a hierarchical node system. Given a world space transform, I need to obtain the transform for a specific node in local space. My Node class has the ...
402 views

### Mode 7 in xna/monogame

I want achieve a view like Mode 7 from snes games where the closer textures get stretched out more and more far away textures look smaller. Something like this: What I have in my project at the ...
705 views

### How to rotate camera using mouse?

I'm looking for a basic example of rotating camera using the mouse. the only problem is I'm not sure of how to rotating the camera around it target. should i do this by an algorithm or is there a ...
133 views

### Rotation, what is the Matrix?

From a previous question, thank you very much by the way, but what on earth is the Matrix of? I'm very new to Mono/XNA and finding any meaningful documentation is ...
94 views

### Recap on how a camera works in 3d Space?

This may be marked as a duplicate, but I have been trouble thinking about a camera. I understand that there is a "camera transform," or view matrix. However, this is multiplied with every vertex in ...
89 views

### Rotate object from an origin using a transformation matrix

I'm making a project in lib GDX and I want to rotate an object by changing the transform matrix of the sprite batch to one that rotates an object rendered on screen a given number of degrees from a ...
190 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 ...
98 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 ...
98 views

### Terminology for the way Transformation Matrix Data is treated

I recently asked a question at math stack exchange and realize a similar questions is more suited for this forum, but the original is here: https://math.stackexchange.com/questions/1526601/...
99 views

### Last Row of the perspective projection matrix

Could you explain to me what is the purpose of -1 in the last row of the gl_projection matrix? And how it affects the perspective division step ?
127 views

### How can I get projected coordinates of vertex on screen

I want to check picking for faces and for that I need projected X Y coordinates of my vertexes in -1 to 1 range: For that I multiply my vertex array with matrices and then get projected triangle ...
1k views

### Cumulative transformation matrices for hierarchical object transformations

I'm having a small issue with my design for hierarchical 3D objects. I'll try to sum things up concisely. Every object has a vector3 for its position, scale, and rotation, as well as a std::vector of ...
459 views

### Tweening back from arbitrary 3D rotation in javascript

I'm using a 3D javascript library to rotate the vertex of a 3D object with a classic 3x3 matrix, to an arbitrary angle in the 3D space, as depicted in the image below. For example, a first rotation ...
264 views

### Change value of uniform for each VAO

I've heard from several sources that it's a better approach to pass the model matrix to a shader via a uniform rather than an attribute. I also know that the idea of a uniform is, that it has the ...
563 views

### Applying Transformation Matrices to VBOs in OpenGL

So I've recently tried to add Vertex Buffer Object Matrix transformation to an OpenGL engine I'm working on. I could go about this by applying the matrix to a copy of each vertex individually, but ...
73 views

### Strange behavior with transformation matrix

I'm fairly new to transformation matrices. I'm using them to translate and rotate nodes and their child nodes. The following code works when applied once, but shows strange behavior when applied many ...
1k views

### Tetris: 2D Rotation Matrix?

I'm creating a Tetris clone right now. I've got the tiles of tetromino stored as an std::array<tile, 4>. Each ...
1k views

### Matrix transform from one coordinate system to another

I have been beating my head against the wall for weeks on this and it is time I just break down and ask for help. I need to move a 3D camera from an in house system into Unreal 4. The two use ...
106 views

### Is it normal in skeletal animation to NOT consider the translation component in bone transform matrices?

I'm using assimp to load a model, and DirectX11 and DirectX ToolKit to render it. In the document of DirectXTK's IEffectSkinning, it says: As an optimization, SkinnedEffect and DGSLEffect assume ...
182 views

### Rotating a 4D matrix about the Y axis with an X-Z vector

I should mention that I'm pretty new to Matrices and will probably need a layman's answer to my question. I have a 4D matrix which represents the rotation of an object in 3D space. I have a ...
120 views

### How much to roll Z to make horizon level

I've got a flying camera with some arbitrary rotation. (It also has a translation, but that's not important.) It's flying along its local Z axis, traveling in some direction over the ground with some ...
1k views

### How to transform a matrix's local space position into another's local space

When looking at an example to learn how to do per pixel collision, I came across this: ...
349 views

### Why would this scaling matrix have no effect?

To draw a simple model using the DirectXTk, I'm doing the following. It all works perfectly, draws correct, and so on. Except changing the scaling factor makes NO difference, and I can't figure out ...
424 views

### Using glm to rotate the modelview matrix based on the cursor position

I am rendering a 3D model of an object, and I want the user to be able to rotate around that object by dragging the mouse. To do this, I want to use the cursor position to continually update the ...
1k views

my function: ...
449 views

### XNA 2D rotation Matrix offset/origin

I'm currently struggling with finding the offset for my original camera translation after I have applied a rotation for it. ...
315 views

### opengl matrix multiplication

Can someone provide some type of example of multiplying a 4x4 matrix without using loops? typedef struct matrix4 { data[16]; } m4; can someone provide a ...
84 views

### Camera (pole cam) implementation problem

In my project I have simple scene graph to render whole scene and Bullet physics SDK to provide physics simulation. Each rendered object is represented as scene node. Camera always has target and ...
757 views

### Does converting quaternion to matrix cause a lot of overhead?

This is related to rendering creating a model, view, projection matrix for opengl. While matrix are fairly standard there's a lot of talk about using quaternions for rotations but why would u go from ...
451 views

### How to calculate if a point is contained in rectangular camera viewport with rotation?

I am working with my camera, and am trying to improve it so that I can calculate if a world point is on screen, taking rotation into account. Currently, my camera rectangle is calculated as so: ...