33
votes
Accepted
Why is the transposed inverse of the model view matrix used to transform the normal vectors?
Here's a simple proof that the inverse transpose is required. Suppose we have a plane, defined by a plane equation $n \cdot x + d = 0$, where $n$ is the normal. Now I want to transform this plane by ...
20
votes
Accepted
Cause of shadow acne
Image 1: A bad case of shadow acne. (Synthetic and a bit exaggerated)
Shadow acne is caused by the discrete nature of the shadow map. A shadow map is composed of samples, a surface is continuous. ...
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 ...
15
votes
Why are Homogeneous Coordinates used in Computer Graphics?
They simplify and unify the mathematics used in graphics:
They allow you to represent translations with matrices.
They allow you to represent the division by depth in perspective projections.
The ...
11
votes
Why is the transposed inverse of the model view matrix used to transform the normal vectors?
This is simply because normals are not really vectors! They are created by cross products, which results in bivectors, not vectors. Algebra works much different for these coordinates, and geometric ...
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} \...
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_{...
10
votes
Cause of shadow acne
As an addition to the answer of joojaa:
Using a bias to offset the shadow function does indeed solve the problem with shadow acne, but it can introduce an additional problem: Peter Panning
As you see ...
9
votes
How to combine rotation in 2 axis into one matrix
(This answer is essentially the same as Stefan's but I wanted to add some detail about row and column vectors, and how to determine which you are using.)
Yes, this is possible, but the details depend ...
7
votes
Accepted
Is there a way to script image creation?
ImageMagick is a set of command-line tools that can do the sort of things you describe. For example, this command line will overlay picture B with a centered copy of picture A, resized to 100 pixels ...
7
votes
Why are Homogeneous Coordinates used in Computer Graphics?
It's in the name: Homogeneous coordinates are well ... homogeneous.
Being homogeneous means a uniform representation of rotation, translation, scaling and other transformations.
A uniform ...
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}=\...
7
votes
Accepted
Ray Transformation to Object Space for Motion Blur
Lerping the ray positions/directions between keyframes should be equivalent to lerping the inverse matrices between keyframes and transforming by the lerped matrix. Trouble is, if the keyframes have ...
7
votes
Accepted
How to invert an affine matrix with small values?
I found a solution to my specific problem. Instead of computing the determinant and hitting the precision wall, I use the Gauss-Jordan method step by step.
In my specific case of affine ...
7
votes
Accepted
Moving each point of a surface in direction of corresponding normal
No this cannot be modelled by (non-uniform) scaling. It's fairly easy to construct a counterexample:
The issue is that the amount a section of the curve/surface grows depends on its curvature, not ...
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 ...
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 ...
7
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 ...
6
votes
How to combine rotation in 2 axis into one matrix
Yes, just multiply them in reverse order:
Matrix myrotation = Matrix.CreateRotationX(xrot) * Matrix.CreateRotationZ(zrot);
EDIT.
My answer only applies if you ...
6
votes
Accepted
Graphics Pipeline: Viewspace & Back face culling incorrectly
I (believe) I've solved this (even if it has taken 2 days). My problem was essentially I wanted to take the dot product of the face normal, and line-of-sight vector like below
And determine the angle ...
6
votes
Rotate line around center
Trick is, to move the entire object so that the point about which you want to rotate is at the center. Then rotate and after that counter move it so that the point is were it was.
In fact this is not ...
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 ...
6
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 ...
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 ...
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, ...
5
votes
Accepted
Angle between two points in Cartesian coordinate system C++
The parametric equation for a spiral is:
$$
\begin{eqnarray}
\begin{aligned}
x &= &(a + b \theta) \times \cos(\theta)\\
z &= &(a + b \theta) \times \sin(\theta)
\end{aligned}
\...
5
votes
Accepted
Calculate aspect ratio from 2D shape in 3D space
The ratio is with a quick and dirty visual measurement $665:501$ which is approximately $5:4$. You can measure it by taking the ratio of the vanishing angles $\alpha/\beta$ (see picture 1) because we ...
5
votes
Transform a point into another point
The hint with the perspective division was already mentioned by ratchet freak, but I'd like to add some explanation of how to come up with the solution.
First of all, remember that homogenous ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
transformations × 2293d × 49
matrix × 35
opengl × 27
projections × 27
mathematics × 21
perspective × 18
raytracing × 17
affine-transformations × 16
computational-geometry × 15
camera × 15
camera-matrix × 15
algorithm × 14
geometry × 13
2d × 11
rendering × 9
normal-mapping × 8
linear-algebra × 8
shader × 7
mesh × 7
glsl × 5
c++ × 5
animation × 5
2d-graphics × 5
interpolation × 4