# Document why Basis axis vectors are exposed transposed #26432

Open
opened this Issue Mar 1, 2019 · 10 comments

Projects
None yet
6 participants

### TyTYct commented Mar 1, 2019 • edited

 Godot version: 3.1 beta 9 OS/device including version: Windows 10 Issue description: print spatial.transform.basis is wrong I tested some case and this happen when spartial angle between 0 and 180 degree. it is ok at angle 180 degree or 0 degree Steps to reproduce: Minimal reproduction project: test transform.zip

Contributor

### PapaFl commented Mar 1, 2019

 `Basis` is not transposed when converted to `String`. (or the other way around maybe?) This results in different output. Not sure if this is an issue/bug.

Member

### akien-mga commented Mar 1, 2019

 It's not a bug a priori, Basis exposes its axis vectors transposed indeed. This should be better documented.

Contributor

### Zylann commented Mar 1, 2019 • edited

 Wait, so with this into account, is `-z` forward, `x` right and `y` up? If not, that's yet another piece of info coders have to know to get them, and another reason to support shortcuts #26371
Member

### Calinou commented Mar 1, 2019 • edited

 Wait, so with this into account, is `-z` forward, `x` right and `y` up? According to `Vector3.FORWARD`, `Vector3.RIGHT` and `Vector3.UP`, yes 😃
Contributor

### Zylann commented Mar 1, 2019 • edited

 @Calinou those are constants, I mean taking any basis, rotated randomly, are `x`, `y` and `z` vectors still going to represent the same axes we see in the editor? Edit: they do, ignore me :p
Contributor

### PapaFl commented Mar 1, 2019 • edited

 Just to clear any confusion: Transform.basis basically is a 3x3 matrix used for rotation (and scale). Multiplying `Basis * Vector3` rotates the Vector3, So multiplying the forward axis vector with a Transform.basis results in a vector pointing "forward" for that transformation. If we look at how Matrix * Vector multiplication works: ``````[a b c] [ j ] [j*a + k*b + l*c] [d e f] * [ k ] = [j*d + k*e + l*f] [g h i] [ l ] [j*g + k*h + l*i] `````` we can see that if the Vector is `Vector3(0, 0, -1)` This basically results in: ``````[ -c ] [ -f ] [ -i ] `````` which is equal to `-Basis.z` exactly because Basis is exposed transposed.
Author

### TyTYct commented Mar 2, 2019

 I confuse why transform.basis is different from transform.basis.x, transform.basis.y, transform.basis.z. I think that transform.basis.x is a part of transform.basis.
Contributor

### PapaFl commented Mar 2, 2019

 You're right that Basis.X (and Y, Z) represent a part of Basis. As i mentioned above, Basis is a 3x3 Matrix. Basis.X basically gives you one column of the matrix: `````` [a b c] Basis = [d e f], Basis.X = [a, d, g] [g h i] `````` However `print(Basis)` prints the Basis row by row. I've tried to make this clear in this image:
Author

### TyTYct commented Mar 2, 2019

 thanks, @PapaFl . I understood that. It is not a bug.

Member

### akien-mga commented Mar 2, 2019

 I still think it needs better documentation though.