Skip to main content
17 votes
Accepted

What is the correct order of transformations scale, rotate and translate and why?

Usually you scale first, then rotate and finally translate. The reason is because usually you want the scaling to happen along the axis of the object and rotation about the center of the object. In ...
JarkkoL's user avatar
  • 3,636
11 votes
Accepted

Computing a rotation: complex numbers vs rotation matrix

Both methods end up doing the same calculations when you break it down. Rotating a vector $u$ with a matrix: $$\begin{bmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{bmatrix} \...
Nathan Reed's user avatar
  • 25.1k
11 votes
Accepted

Is it possible to turn a 3d rotation matrix (4x4) into its component parts (rotation, scale, etc.)?

You can decompose the matrix $\mathbf{M} = \mathbf{TRS}$ into basic transformations: translation, scaling, and rotation. Given this matrix: $$\mathbf{M} = \begin{bmatrix} a_{00} & a_{01} & a_{...
user5488's user avatar
  • 156
8 votes
Accepted

Why do I need to inverse the orientation matrix of a camera to be able to translate it in the direction it is facing?

People always forget that there is no "camera" in OpenGL. In order to simulate a camera you have to move the whole world inversely. So if you want ur camera looking 30 degrees downward, you move the ...
gallickgunner's user avatar
7 votes

Why are Homogeneous Coordinates used in Computer Graphics?

Imagine you want to represent transformations using matrices. Points could be stored as $$\begin{bmatrix}x\\y\end{bmatrix}$$ and you could represent a rotation as $$\begin{bmatrix}u\\v\end{bmatrix}=\...
Chuck's user avatar
  • 296
7 votes

Is there a objective reason for matrix naming conventions?

I think the naming order is intuitive because it is in reading order (left to right), e.g., worldViewProjection means that your point/direction is first multiplied by the world matrix, then the view ...
vgs's user avatar
  • 311
7 votes
Accepted

Zoom in orthographic vs perspective projection

Perspective projection changes the size of an object as it's distance changes, while orthographic projection does not. That is part of the definition of those projection types. To simplify things a ...
Alan Wolfe's user avatar
  • 7,801
7 votes

Can a scene graph be stored in the GPU?

Short answer: Yes, It can be done. But no one does so. Long answer: Scene graphs can be stored and processed on a GPU using OpenCL/WebCL. But it is not practical to do so. Updating scene graphs (a ...
Mary Chang's user avatar
6 votes
Accepted

Animating a smooth linear transformation

As a general rule, you cannot interpolate transformation matrices. In stead, you decompose them into their individual values, then interpolate those and recompose. The Möbius transformation as ...
Paul-Jan's user avatar
  • 266
6 votes
Accepted

Minimum requirements to uniquely represent a 3D object in space

A rigid body has 6 degrees of freedom, in 3D- space. So that means you need 6 values to represent the object. The common way to do this is to store a position vector for position and 3 rotations. But ...
joojaa's user avatar
  • 8,437
6 votes

Gimbal lock confusion

Gimbal lock is your item 1. It is the situation where we have rotated our 2nd axis (in the order of application of the three axes) by ±90 degrees, which aligns the 1st axis and the 3rd axis together, ...
Nathan Reed's user avatar
  • 25.1k
5 votes
Accepted

Apply distortion to Bézier surface

Edit: changed the answer according to new images and clarification. for every control point p(k, n) p'(k, n) = ( p(k, n) - p(k) ) * d * l(k) + p(k, n) where <...
Cem Kalyoncu's user avatar
5 votes

Unwinding an image on a spiral to make it long and flat

A quickly formulated method, read first one that popped in my brain (not best), could be. Find the closest points on a parametric spiral for each sample (read A Pixel Is Not A Little Square3). Then ...
joojaa's user avatar
  • 8,437
5 votes
Accepted

3D rotation matrix around vector

There is a direct formula for the rotation matrix for an arbitrary axis and angle. Given a unit vector $a = (a_x, a_y, a_z)$ and angle $\theta$, the matrix can be constructed as follows (derivation ...
Nathan Reed's user avatar
  • 25.1k
5 votes

Is there a objective reason for matrix naming conventions?

The order is arbitrary, but if you want to be compatible with physics textbooks then your notation is mostly set. The difference is that you seem to think that its more natural to observe the systen ...
joojaa's user avatar
  • 8,437
5 votes

How is that possible that matrices can be thought as coordinate systems?

If you have a 3x3 matrix representing some transformation, you will actually have the X,Y,Z vectors of that transformation in the rows or columns (depending on if it's a row major or column major ...
Alan Wolfe's user avatar
  • 7,801
5 votes

why is translating in 3D space the same as shearing in 4D space?

In a linear transformation system, your origin is always a fixed point, since 0*anything = 0. So imagine you have a cinema screen, and the origin is at the centre of the screen. Using linear ...
russ's user avatar
  • 2,402
5 votes
Accepted

Why does this gl_FragDepth calculation work?

What you are missing is, that in OpenGL's NDC space (i.e. clip space after division by w) all 3 coordinates are in the range $[-1,1]$. So ...
Christian Rau's user avatar
5 votes

How to keep an object constant in screen space?

Scale the object proportional to its depth (z in camera space) and it will retain the same size on screen regardless of its position in world space. Additionally, you might also wish to scale the ...
Nathan Reed's user avatar
  • 25.1k
5 votes
Accepted

What is this graphical effect called?

I don’t think there’s a formally established name for it, but it’s generally known as distortion, warping, or refraction. It works by taking an already rendered version of the current frame, sampling ...
Noah Witherspoon's user avatar
4 votes

Image rotation algorithm

It speed does not matter, I suggest to use a truncated sinc or a Lanczos isotropic kernel: to compute a target pixel, you back-rotate the filter and convolve it with the image. Since it is isotropic, ...
Fabrice NEYRET's user avatar
4 votes

Image rotation using FFT

Yes, it is possible. Remember that a shift in space is equivalent to a linear-phase multiplication in frequency. A rotation can be accomplished by a shearing operation in one direction followed by a ...
Stan Reeves's user avatar
4 votes
Accepted

Affine Transformation

It is not necessarily affine. An affine matrix in homogeneous coordinates has a form like: $$\begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ 0 & 0 & 1 \...
Nathan Reed's user avatar
  • 25.1k
4 votes

Computing camera front direction from Euler angles

This kind of navigation works well for situations that are centered about objects. It keeps the up vector always pointing upward which makes it less possible for confusion. Bringing quaternions into ...
joojaa's user avatar
  • 8,437
4 votes
Accepted

implementing right handed coord system APIs on top of a left-handed rendering engine

What you probably need is this 4 x 4 matrix: $$\mathtt{T} = \begin{bmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & -1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{...
NodeCode's user avatar
  • 341
4 votes

Screenspace Normals - Creation, Normal Maps, and Unpacking

How are screenspace normals created, and is this step before or after using normal maps or bump maps? They are created after using normal maps. In deferred rendering, you write to the various buffers ...
aces's user avatar
  • 1,353
4 votes
Accepted

Transformation Matrices

The answer in the screenshot is wrong on two counts. First, you're correct that in the middle matrix the −1 should be on the third row, not the second. The other error is that the $u, v$ basis vectors ...
Nathan Reed's user avatar
  • 25.1k
4 votes

Transforming fragment-to-camera to tangent space for parallax occlusion mapping

Without looking at the code, from the look of the pictures, my intuition would be that somewhere the code is using the inverse of the matrix it should. Looking at the code seems to confirm so, but ...
Julien Guertault's user avatar
4 votes

What's a parent vector space or coordinate system?

You have to step outside the world of mathematics for a while and look at what we are trying to achieve. Mathematics in its purest form only tells us what kinds of properties certain constructs have, ...
joojaa's user avatar
  • 8,437
4 votes
Accepted

Calculate a rotation around an arbitrary axis

Take a point $P$ and it's rotated point $P'$. Find the plan that runs through the middle between them $C = \frac{P+P'}{2}$ and is perpendicular to the line connecting them. Do this for all 3 of them ...
ratchet freak's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible