74
votes
Accepted
I'm rotating an object on two axes, so why does it keep twisting around the third axis?
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'...
46
votes
Accepted
What is the standard practice for animating motion -- move character or not move character?
Animations in which the character translates away from the origin are said to contain "Root Motion" - because the root bone moves.
This allows the animator to directly author subtle non-...
24
votes
Accepted
Using Quaternions: What can I do with them? (without the maths)
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.
...
17
votes
How does a 4x4 matrix represent an object in space and matrix lore?
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 ...
15
votes
Accepted
Why do we need a fourth coordinate to divide by z?
Because if you only divide [x, y, z] by z you get [x/z, y/z, 1] and you lost the actual ...
15
votes
Using Quaternions: What can I do with them? (without the maths)
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 ...
12
votes
How to extract euler angles from transformation matrix?
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/...
11
votes
How and when do the model to world, world to view, et cetera multiplications happen?
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 ...
10
votes
Accepted
Does vector transformation order matter?
Because of the linearity (aka distributive property) of vector addition and matrix multiplication, it doesn't matter! Yay!
...
9
votes
Accepted
LibGDX viewport touch coordinates transformation
I hope I am understanding your question correctly -- if not let me know.
I believe the following is where you are unprojecting the coordinates:
...
8
votes
Accepted
Do matrix manipulations for 3D graphics ever produce singular matrices?
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 ...
8
votes
Accepted
In Unity, how to get reference of descendant?
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 ...
6
votes
Accepted
Is it more efficient to transform vertices on the CPU or the GPU?
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 ...
6
votes
Accepted
Stop movement if transform.position.y == 0
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
...
5
votes
Accepted
How to mirror/reflect/flip a 4D transformation matrix
To get a transformation matrix equivalent to the one you have, but reflected across a major axis you can compose it (multiply it by) a reflection matrix.
That is, if you have your input matrix M and ...
4
votes
Accepted
Transform world space using Kinect FloorClipPlane to move origin to floor while keeping orientation
You're looking for a change of basis. The way to do it is to find the coordinates of the new basis in the old one.
For simplicity, we'll say that the ...
4
votes
How can I stop transform.position from being modified when adding a child object?
There is a different way.
Instead of:
child.transform.parent = parent.transform;
Use:
...
4
votes
Accepted
what is the very last element of a 4x4 transformation matrix for?
The value is for Homogeneous Coordinates. Using homogeneous coordinates makes it possible to use things like quaternions and projection matrices. The last entire row is actually for dealing with ...
4
votes
Accepted
Inline-Building a World (SRT) Matrix
A homogenous transformation matrix (aka a "World matrix") is a 4x4 matrix that defines the translation and rotation of one coordinate system with respect to another. It looks like this:
...
4
votes
Unity C# Object Scaling when parenting by script
I'm assuming your question is about the scale change that occurs at the moment you parent one object to another with a net scale other than (1, 1, 1). This can be avoided, as described below. Any ...
4
votes
Fastest way to neutralize scale in the transform matrix?
Assuming your matrix multiplication follows the convention...
M * v = (T * R * S) * v
(where M is your composed matrix, ...
4
votes
Accepted
Extract a rotation matrix given a camera direction (vector) and a up vector for the camera?
NOTE: Edited because it was likely too verbose (source).
A rotation matrix actually always defines an orthonormal basis. What this means is each column defines one of your original axes in its ...
4
votes
Accepted
How to get an game object to instantiate lower than where It's created?
ally = (GameObject)
...is a syntax error. You need to comment this line just like you did the one below it.
The problem is on that line, but because it's so ...
4
votes
Accepted
Unity / Rotate a point around an arbitrary axis and anchor
The concept of a "rotation" is represented by a Quaternion. These are built into Unity and there's no need for you to understand the math in that link you posted.
To create a rotation from an angle &...
4
votes
Detect transform from detection of QR code?
Deriving the transformation
Note that the transformation of the QR code captured by the camera is a perspective transformation. As such, no amount of affine transformation can emulate it (translating,...
4
votes
Calculate vector3 global point projecting it in local space using Unity and C#?
Let's say you have a trasnformed coordinate system defined by a quaternion rotation, and vector3 position. For example, the ...
4
votes
Accepted
LookRotation() make X axis face the target instead of Z
I've answered a few flavours of this before.
The basic idea is to chain together two rotations: one that takes the axes you want to align and points them along z+ and y+ respectively, and then the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
transformation × 472unity × 162
matrix × 104
rotation × 87
c# × 79
opengl × 63
mathematics × 63
3d × 39
c++ × 31
2d × 31
camera × 28
vector × 22
quaternion × 22
linear-algebra × 22
scale × 16
movement × 15
coordinates × 15
geometry × 14
java × 13
animation × 13
glm × 13
xna × 11
graphics × 10
models × 10
javascript × 9