Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document why Basis axis vectors are exposed transposed #26432

Open
TyTYct opened this Issue Mar 1, 2019 · 10 comments

Comments

Projects
None yet
6 participants
@TyTYct
Copy link

TyTYct commented Mar 1, 2019

Godot version:

3.1 beta 9

OS/device including version:

Windows 10

Issue description:

print spatial.transform.basis is wrong

image

image

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

image

Steps to reproduce:

Minimal reproduction project:

test transform.zip

@TyTYct TyTYct changed the title print basis print spatial.transform.basis is wrong Mar 1, 2019

@StraToN StraToN added this to the 3.1 milestone Mar 1, 2019

@PapaFl

This comment has been minimized.

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

@akien-mga akien-mga removed this from the 3.1 milestone Mar 1, 2019

@akien-mga

This comment has been minimized.

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

@akien-mga akien-mga changed the title print spatial.transform.basis is wrong Document why Basis axis vectors are exposed transposed Mar 1, 2019

@Zylann

This comment has been minimized.

Copy link
Contributor

Zylann commented Mar 1, 2019

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

@Calinou

This comment has been minimized.

Copy link
Member

Calinou commented Mar 1, 2019

Wait, so with this into account, is -z forward, x right and y up?

According to Vector3.FORWARD, Vector3.RIGHT and Vector3.UP, yes 😃

@Zylann

This comment has been minimized.

Copy link
Contributor

Zylann commented Mar 1, 2019

@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

@PapaFl

This comment has been minimized.

Copy link
Contributor

PapaFl commented Mar 1, 2019

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.

@TyTYct

This comment has been minimized.

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

@PapaFl

This comment has been minimized.

Copy link
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:
trp

@TyTYct

This comment has been minimized.

Copy link
Author

TyTYct commented Mar 2, 2019

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

@TyTYct TyTYct closed this Mar 2, 2019

@akien-mga

This comment has been minimized.

Copy link
Member

akien-mga commented Mar 2, 2019

I still think it needs better documentation though.

@akien-mga akien-mga reopened this Mar 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.