Tag Info

Hot answers tagged

48

Why ? Because, A camera represents a projection view. But in case of 3D Camera (Virtual Camera), camera moves instead of the world. I have made a detailed explanation later of this answer. Understanding Mathematically Projection View moves around space and change its orientation. The first thing to notice is that the desired projection on the ...


17

Mahbubar R Aaman's answer is quite correct and the links he provides explain the math accurately, but in the event you want a less technical/mathy answer, I'll try a different approach. Positions of objects in the real world and the game world are defined with some coordinate system. A coordinate system gives meaning to position values. If I tell you that ...


9

Just adding to the other two (excellent) answers some further elaboration on a point that Mahbubur R Aaman touched on: "there is no camera". This is quite true and represents a failing of the common "camera" analogy, because the "camera" does not actually exist. It's important to realise that the camera analogy is just exactly that - an analogy. It ...


6

Mathematically, the quantity you're asking about is called the operator norm. Unfortunately, there's no simple formula for it. If it's a fully general affine transformation - for instance, if it could have an arbitrary combination of rotations and nonuniform scales, in any order - then I'm afraid there's nothing for it but to use singular value ...


5

From the image it looks like both your coordinate systems are cartesian coordinates, where the only difference between the two is that one has a different origin from the other. If this is the case then to translate from xyz coordinates to x'y'z' coordinates all you need is a translation, i.e. x' = x + dx y' = y + dy z' = z + dz Where [dx, dy, dz] is the ...


5

I'm not sure of a good way to preface this, other than I hope it ties together nicely by the end. That said, let's dive in: A rotation and an orientation are different because the former describes a transformation, and the latter describes a state. A rotation is how an object gets into an orientation, and an orientation is the local rotated space of the ...


5

You can check if cross(up, zaxis) is too close to zero (use an epsilon like 1e-4 or something like that), and switch to an alternative up-vector if so. For instance, if your usual up-vector is (0, 1, 0), you could switch to (1, 0, 0).


4

If you are sure your has a uniform scale and no skew components, then the non-translation part of the matrix can be expressed as M_33 = R * (s * I), where R is the an orthogonal rotation matrix, and s is the uniform scale. This is vaguely annoying so solve, but in 3d comes out to be: scale_x = sqrt(m00^2 + m01^2 +m02^2); // scale_y = sqrt(m10^2 + m11^2 ...


4

You need a combination of scale and translation matrices. You could first go to a "normalized" screen space (origin at 0,0 and scaling to 1,1) using, in pseudo-code: MatToNormalized = Translation(-1, -1) x Scale(1/2, 1/4) Then you can easily map to any kind of screen space. E.g. for question 1.: MatToFullscreen = MatToNormalized x Scale(600, 500) And ...


4

To implement Lorentz contraction, your best bet is probably just to explicitly scale the object by 1/gamma along the direction of motion. The trouble is that the Lorentz transformation displaces vertices in the time direction as well as in space, so by itself it will not give you what a moving object looks like at a specific moment in time. To do that, you ...


4

Rotating a point p using a quaternion q is done with q * [0, p] / q. Replacing q with -q has absolutely no effect on the result. If your rotations "go the wrong direction" when the sign of the quaternion changes, then the problem lies in the way you use the quaternions to rotate points.


4

Expressing rotations with quaternions can be done from an axis-angle representation, but not in a single way. For that same axis angle (w, a) pair, you get two quaternions performing the same task. One has its components based directly on the w vector and the a angle, the other has the same components, but negated. This is normal, since they describe the ...


4

I would posit instead that it's a flawed analogy. At its most basic, "moving the camera" and "moving the world" are exactly the same mathematical construct - it's just that moving the world is somewhat easier to think about conceptually, especially when it comes to hierarchical transformations. Basically, you're moving the world around the camera only in ...


4

Moving the camera or moving the world are two equally valid choices which both amount to the same thing. At the end of the day you are changing from one coordinate system to the other. The above answers are correct but which way you visualise it are two sides of the same coin. Transformations can go either way - they are just the inverse of each other. Part ...


4

I don't think that the claim is categorically true, as one only rarely "moves" the world coordinates in a game, but actually changes the coordinates of the virtual camera. What the concept of camera actually does, is transform the finite viewing frustum -- that is a truncated pyramid with 8 corner points (or defined by intersection of 6 planes) to a unit ...


4

OpenGL is a state-machine, it has a current matrix. There are several functions to manipulate the current matrix: glLoadIdentity, glLoadMatrix overwrite the current matrix. glTranslate, glScale, glRotate, glMultMatrix multiply the current matrix with the appropriate matrix generated by these functions from the right. Now, whenever you draw something it ...


4

What you are looking for is the LookAt algorithm. OpenGL already has that in a nice function: gluLookAt, although it multiplies the current matrix instead of returning it to you so you may need some push/pop trickery to get at it. If you want to do it yourself, there are two ways; by constructing a transformation matrix, or by using quaternions. Here's the ...


4

The best way to gain intuition about how a matrix behaves is by determining its effect on the standard basis vectors: 1 0 0 e1 = 0 e2 = 1 e3 = 0 0 0 1 Since any 3D vector can be written as a combination of a*e1 + b*e2 + c*e3, if we know how a matrix changes these three vectors, we know how a matrix changes any ...


4

Local versus world is just a matter of the order in which you compose transforms. For instance, when using row-vector math, multiplying the current local-to-world transform by a new transform on the left will perform the new transform in local space, since it will be equivalent to doing the new transform followed by the old local-to-world transform. ...


3

Three points, A, B and C define a plane. The lines AB and AC are both on the plane, so their normalised cross product, perpendicular to both lines, is the plane's normal n: n = normalise( (B - A) ⨯ (C - A) ) The equation for the plane is given by: n · x + d = 0, where -d is the displacement between the plane and the origin in the normal direction, i.e.: d ...


3

Just take the desired movement vector, multiply it by the object's rotation matrix, then use the result as before, i.e. convert it to a translation matrix and multiply it into the position_mat.


3

Quite a common thing to do with some matrices is to cache the value and only update it when it's changed. There's two ways to manage this scheme, push or pull. Pushing matrices would involve, at the point of a matrix changing, letting child nodes know that the matrix has changed. These nodes will then have to let their children know, and so on. The upside ...


3

The matrix I'm using is a row-major matrix used by OpenGL. Here's what it looks like: [ X1 Y1 Z1 WX ] [ X2 Y2 Z2 WY ] [ X3 Y3 Z3 WZ ] [ TX TY TZ CZ ] What you have is actually three matrices: a rotation matrix, a scale matrix and a translate matrix. This is because virtually any 4x4 matrix can be broken down to two or more matrices that together form the ...


3

Given the following: A as the 4x4 augmented translation matrix to move any of the point of the plane into the origin I as the 3x3 identity matrix N as the 3-dimensional unit normal vector for the plane (calculable by creating a dot product from any two non-parallel lines on the plane, then normalising them) The calculation steps for the augmented ...


3

This type of transformation cannot be done with a (single) matrix; those can only handle linear transformations, and the image you posted plainly shows a non-linear transformation. (A linear transformation could deform the sphere into an ellipsoid, but it couldn't produce a waist in the middle like that.) I'm going to assume that what your professor meant ...


3

Rather than trying to transform your tetrahedron into an icosahedron, work backwards. Construct your icosahedron, then pick four "opposite" faces of the icosahedron (like the blue or the red ones in your animated image). The four faces you picked will be the red ones from the animation, which condense into one corner point of the tetrahedron each (green ...


3

(a) To produce a "squash" matrix that smashes things to the ground plane parallel to a given sun vector, I would build it by composing two matrices: A shear matrix that maps the sun vector to +Y (straight up) while leaving the X and Z axes unchanged. A scaling matrix that scales Y by zero while leaving X and Z unchanged. Specifically, assuming you're ...


3

It's the other way around. Changing the transformation matrix doesn't do anything to what has already been drawn. It only affects what is going to be drawn. Think of your matrix stack as a bunch of filters which your vertices get sent through when you send them to the video card. An identity matrix does - by definition - nothing when multiplied with another ...


3

First of all the resulting shape is not a parallelogram but a trapezoid. From what you write I gather that you are using the fixed-function pipeline rather than the programmable pipeline (which makes the solution really quite obvious). Basically what you need to do is perform the processing of the vertices again the same way as OpenGL does. This is the only ...


3

Normally I store all objects as 4x4 Matrices (you could do 3x3 but easier for me just to have 1 class) instead of translating back and forth between a 4x4 and 3 sets of vector3s (Translation, Rotation, Scale). Euler angles are notoriously difficult to deal with in certain scenarios so I would recommend using Quaternions if you really want to store the ...



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