# Tag Info

72

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

52

No this isn't an engine bug or an artifact of a particular rotation representation (those can happen too, but this effect applies to every system that represents rotations, quaternions included). You've discovered a real fact about how rotation works in three-dimensional space, and it departs from our intuition about other transformations like translation: ...

28

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

23

Multiplication At least in terms of Unity's implementation of Quaternions, the multiplication order described in the question is not correct. This is important because 3D rotation is not commutative. So, if I want to rotate an object by rotationChange starting from its currentOrientation I'd write it like this: Quaternion newOrientation = rotationChange * ...

14

Because if you only divide [x, y, z] by z you get [x/z, y/z, 1] and you lost the actual value of z, which is actually useful if you want to do near/far plane clipping or fill a Z-buffer. The best way to keep some information about z, at least on the GPU, is therefore to use 4 components instead of 3. In practice, what is actually in the last two vector ...

13

Where's the dot product used? In Unity, one of the most common users of the dot product is whenever you check if two quaternions are equal via == or !=. Unity computes the dot product to check similarity rather than directly comparing the internal x,y,z,w values. It's worth keeping this one in mind as it makes the call more expensive than you might expect ...

11

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 doesn'...

11

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

11

Yes, the Update loop is ideal for this. There are no special plug-ins required and you can do this with the free version. Basically you move the objects a tiny bit towards their destination each frame. When all those frames run one right after the other, it gives the appearance of smooth movement. A self contained script would look like the one I've created ...

11

Think about it logically: What is your goal when you render something? To display it on the screen! What are the constraints? The model must be visible to the camera (i.e. in the view frustum, not occluded by other objects, etc.) What are the inputs? A collection of vertices in a coordinate system local to the model's origin. A transformation matrix that ...

10

Because of the linearity (aka distributive property) of vector addition and matrix multiplication, it doesn't matter! Yay! Transform(Sum(v_i)) = Transform(v_0 + v_1 + ... + v_n) = Transform(v_0) + Transform(v_1) + ... + Transform(v_n) = Sum(Transform(v_i)) EDIT: However, transformations are not commutative, so these ...

9

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

9

There's a great writeup on this process by Mike Day: https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2012/07/euler-angles1.pdf It is also now implemented in glm, as of version 0.9.7.0, 02/08/2015. Check out the implementation. To understand the math, you should look at the values that are in your rotation matrix. In addition, you have to know ...

8

I hope I am understanding your question correctly -- if not let me know. I believe the following is where you are unprojecting the coordinates: @Override public boolean mouseMoved(int screenX, int screenY) { worldCoordinates = camera.unproject(new Vector3(screenX, screenY, 0)); return true; } Because you are using a viewport, you must add the ...

8

Yes, transform.Find(name) will only look in the direct children of the current transform. But if you want to get a child deeper in the hierarchy, you can use slashes to describe the complete path. So transform.Find("Weapon/metarig/upper_arm.R/forearm.L.001/hand.L.001/weapon.L.001/AttackDetection") should work. An alternative might be to use ...

7

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

7

How is Matrix Multiplication a Transformation? A matrix is just a big grid of numbers with rules that define how we can multiply it with other grids or lists of numbers. In games, we usually want to construct a matrix so that, when multiplied with a list of numbers representing a source position (say, the position of a vertex in a mesh) we get a list of ...

6

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

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

6

You are simply copying the main camera's rotation in your code snippet, try this method: GameObject _go = (GameObject)Instantiate(_hitPrefab, collision.gameObject.transform.position, Quaternion.identity); _go.transform.LookAt(Camera.main.transform); http://docs.unity3d.com/Documentation/ScriptReference/Transform.LookAt.html You should also have a ...

6

In short - it is better to do the transformation on the GPU. Firstly, the GPU is designed to support huge amounts of parallelisation. Your CPU on the other hand is not nearly as capable. The NVIDIA GTX 980, for example, has 2048 CUDA cores to process those vertices with in comparison to the 2-16 threads/cores a processor might support. So from a number ...

6

The simplest way this can happen is if you shrink an object until its local scale in one or more axes is 0 (flattening it to a plane, line, or point). You can avoid this by disallowing scales below a certain magnitude on any axis. (If your system allows hierarchical nesting of transforms, you'll also have to watch out that no chain of parented matrices ...

6

Because the Y position is never EXACTLY 0. Its for example 5.5 next frame: 4.3 next frame: 3.1 next frame: 1.9 next frame: 0.7 next frame: -0.5 change the if to if (inst.transform.position.y <= 0) Then add: inst.transform.position = new Vector3(inst.transform.position.x, 0, inst.transform.position.z); next to: speed = 0;

5

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

5

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.

5

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

5

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

5

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

5

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 cross product from any two non-parallel lines on the plane, then normalising them) The calculation steps for the augmented ...

5

If you want to rotate an object around.Center must be at the point(0,0,0) To achieve that simply Translate the object to point(0,0,0) Rotate and Translate back example: Translate(0,0,-1) Rotate(90) Translate(0,0,1)

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