# Tag Info

27

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 some matrix $M$. In other words, I want to find a new plane equation $n' \cdot Mx + d' = 0$ that is satisfied for exactly the same $x$ values that satisfy the ...

25

An Affine Transform is a Linear Transform + a Translation Vector. $$\begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix} + \begin{bmatrix}e& f\end{bmatrix}$$ It can be applied to individual points or to lines or even Bezier curves. For lines, it preserves the property that ...

15

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 first one is related to affine geometry. The second one is related to projective geometry.

13

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. Thus, there can be a spot on the surface where the discrete surface is further than the sample. The problem does persist even if you multi sample, but you can ...

13

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 your case you don't really need to worry about this generic solution though, but you only need to map range [0, 800] $\rightarrow$ [-2, 2] for x-coordinate and [...

11

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_{02} & a_{03}\\ a_{10} & a_{11} & a_{12} & a_{13}\\ a_{20} & a_{21} & a_{22} & a_{23}\\ 0 & 0 & 0 & 1 \end{bmatrix}$$ ...

9

(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 on whether you represent your vectors as rows or columns. Column vectors If you are using column vectors, you will normally transform them by left-...

9

I want to start with misconceptions: Modern GPUs (NVIDIA for quite a while, and AMD since Southern Islands) do not meaningfully support vector/matrix operations natively in hardware. They are vector architectures in a different direction: each component of a vector (x, y, z) are generally 32- or 64-valued, containing values for each element in a lane. So a ...

9

Doing math with uniforms is a shader won't usually get you any performance over doing it on the CPU. A CPU isn't slower than a GPU at doing matrix math, it just isn't structured so as to do large amounts of math in parallel. But you have to actually do that large amount of math to get a win. Sending extra data to the GPU just to have the GPU multiply two ...

9

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} \begin{bmatrix}u_x\\u_y\end{bmatrix} = \begin{bmatrix}u_x \cos\theta - u_y\sin\theta \\ u_x \sin\theta + u_y \cos\theta \end{bmatrix}$$ Rotating a vector $u$ ...

8

Fourier transforms wouldn't help you with a rotation. You'd just end up having to rotate the matrix of Fourier coefficients, instead of rotating the original image. Consider for example an image made of a perfect sine wave along the x-axis with wave-vector $(k, 0)$. (The wave-vector is the spacial frequencies along the $x$ and $y$ axes). The Fourier ...

7

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 different rotations, that lerped matrix will in general be something "weird", with shearing, nonuniform scale, etc. I wouldn't be surprised if some of your ...

7

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 representation allows for optimizations. 3D graphics hardware can be specialized to perform matrix multiplications on 4x4 matrices. It can even be specialized to recognize ...

7

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 transformation is just one operation that behaves differently. A great resource for learning more about this is Eric Lengyel's presentation on Grassman Algebra.

7

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 wide (keeping aspect ratio): convert pictureB.png ( pictureA.png -resize 100 ) -gravity center -composite output.png See the ImageMagick docs for more info ...

7

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 transformation matrices and the range of values I use, I don't hit any precision problem this way.

7

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 its orientation in space. Notice here that the circular arc grows uniformly in all directions (by a factor of $3/2$) whereas the length of the horizontal segments ...

7

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 matrix, and then the projection matrix. In this manner, you know the correct multiplication order by just reading the variable name and you do not have to think ...

7

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 tree not in flat memory) on a GPU is slow, and processing it on a GPU is also slow (again, the tree is not in flat memory), while computing transformation ...

7

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 whole world 30 degrees upwards. If you want your camera moved to the left, you move the whole world right. That's why you will notice the "-" sign in the ...

6

It is likely that your specific problem arises from a singularity in atan when m_position.z goes to 0. Rather than try to debug that, I'll point out that you don't need to transform your camera position into an angle to then modify it: rather, just create a rotation from your newPhi and newTheta angles, in the form of a rotation matrix or quaternion, and ...

6

Yes, just multiply them in reverse order: Matrix myrotation = Matrix.CreateRotationX(xrot) * Matrix.CreateRotationZ(zrot); EDIT. My answer only applies if you are using column vectors. Please see Martin Büttner detailed answer.

6

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 to see if the face was looking towards or away from the view point. My erroneous step was that I was doing this AFTER transforming from world-space to view-...

6

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 so much of a trick, as such, nearly all graphics engines work this way. It is just abstracted away in many cases. Most often you will see it done in matrix ...

6

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 in the picture on the left the shadow is disconnected from the shadow casting wall. This gives the impression that the geometry hovers over the ground (just ...

6

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 suggested in the comments sounds interesting, but tradionally I'd just extract scale and rotation and interpolate those. Assuming a transformation matrix | a ...

6

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 bit, a simple perspective projection of a 3d point to a 2d point can be calculated like this: $x_{2d} = x/z\\ y_{2d} = y/z$ As you can see, the 2d version of ...

6

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 for obvious reasons any 6 variables that are independent of each other would do this. The problem with vectors is that they aren't the most efficient way to ...

6

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, so that rotating either one of them does the same thing. From that position, there are some directions we cannot rotate in. For a concrete example, let's say we ...

5

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 coordinates add a fourth value $w$ to your 3D vector. For points in the 3D space, $w \neq 0$ holds and $[x, y, z, w] = [n*x, n*y, n*z, n*w]$ also holds for every $n$. ...

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