+4 votes

The documentation about Transform feels very sparse. It seems to assume that once I have read about Matrix etc. then it will be obvious to me why I want a Transform and how it differs from just using Matrix multiplication. But I think I have confusion and bugs in my code because Transform is different and I don't understand the practical ramifications.

It just feels really confusing to me that anybody decided we had to have anything more than regular matrix math. What does a Transform help/add/give me?!

Is there anybody who has docs or can succinctly explain the salient differences between using Matrix math vs. a Transform? E.g. I want to draw an Asteroids spaceship that has to be (a) scaled, (b) rotated, (c) translated to show it correctly in game.

in Engine by (103 points)

3 Answers

+1 vote
Best answer

A Transform is the combination of a 3x3 matrix and an origin, to be used as a single object. In other engines you can eventually find it as Matrix4, where the origin is occupying the 4th row or the 4th column. However the latter is a bit "internal" and depends on the rendering technology in use.

I deduced this information from the doc: http://docs.godotengine.org/en/latest/classes/class_transform.html
And I assume more can be found in the code, however I don't know why exactly the authors made it this way.

by (27,829 points)
selected by
+1 vote

A transform determines the position and the orientation of an object. "origin" property is a vector to the position of the object (also known as translation vector) whereas "basis" property is a rotation matrix which determines the orientation. The columns of a rotation matrix can be thought as the local axes of the coordinate system "painted" on the object, so it's typically called "basis" in game engines.

by (64 points)
0 votes

A transformation is just the concept of changing some number to another. Translation is a form of transformation. If you have a coordinate X as 100, and you want to move positive 25, you create a formula of X + Movement. This is a transformation. It can be anything, but mainly the interest is in the kinds that move things in meaningful ways on a screen or coordinate space.

Another example is scaling, which would be multiplying some number. If these are coordinates that draw some shape, it will create the illusion of the shape growing or shrinking, or zooming if everything around it is being scaled too.

Matrices are just a mathematical device. They're collections of numbers that can represent a series of multiplications and sums in a compact form. Typically in games the things that get packed into them are the transformation values for scaling, rotating, skewing, and translating. The order is important when creating this "transformation" matrix.

That's a very surface level explanation, but there is quite much more to say. They're certainly topics worth studying for game development. In the end it takes some tinkering with them to see what's going on.

by (5,203 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.