godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.46k stars 21.27k forks source link

Rotating a node 90/180 degrees through the Euler angle rotation mode in inspector does not produce the same basis as using the quaternion or matrix properties. #92898

Open ModularNucleus opened 5 months ago

ModularNucleus commented 5 months ago

Tested versions

Reproducible in:

System information

Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.3758) - AMD Ryzen 5 3600 6-Core Processor (12 Threads)

Issue description

I am unsure if this is actually a bug, because of:

The issue is: When rotating a Node3D 90 or 180 degrees by using the Euler angle properties in the inspector, the resulting basis is not identical to the one produced by performing the same rotation using the quaternion or basis rotation edit modes.

E.g., rotating th x-axis 90 degrees produces the following transform when the scene is viewed in Notepad++: transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)

billede

Rotating the node by pasting the quaternion (0.707, 0, 0, 0.707) into the quaternion field produces the following basis: transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0)

billede

Rotating the node using the basis rotation mode also produces the following basis: transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0)

billede

Switching rotation modes: Switching the rotation edit mode to quaternion or basis modes after having rotated using Euler retains the Euler-derived basis: transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)

billede

Switching to Euler rotation mode after having first rotated via quaternion or basis retains the quaternion/basis-derived basis:

billede

Like I said, I do not really know if this is expected behaviour, e.g., due to precision issues, but it does seem a little odd to me.

Steps to reproduce

Minimal reproduction project (MRP)

rotation_test.zip

AThousandShips commented 5 months ago

This is likely due to rounding errors, the values are very tiny and reasonably within margins for comparison, remember that the angle mode will perform several conversions, first from degrees to radians, and then computing the transform

Mickeon commented 2 days ago

Where should this be documented even, if at all?

tetrapod00 commented 2 days ago

I remember there was talk of documenting all the floating point gotchas somewhere in the manual and then linking to it. I think that place ended up being https://docs.godotengine.org/en/stable/tutorials/physics/large_world_coordinates.html, but it's not linked to all that often, since it's not really a general explanation of floating point. Across the docs, I think there's a link or two to an off-site explanation of floating point, as well.

If this issue is purely caused by generic floating-point precision issues, I think it could be reasonably closed without any documentation changes.