From edf5c7eb2a16cc6c167f1796424fe2ec95cb5f66 Mon Sep 17 00:00:00 2001 From: lschlieder Date: Wed, 8 Oct 2025 23:08:09 +0200 Subject: [PATCH] using transform.basis.orthonormalized() instead of transform.basis when creating Quaternion In the Interpolating with quaternions section, add the .orthonormalized() function to the creation of the Quaternion. While Quaternion(Basis) usually works fine, it fails when the basis is not orthonormalized, as stated in the Quaternion documentation: Quaternion Quaternion(from: Basis) Constructs a Quaternion from the given rotation Basis. This constructor is faster than Basis.get_rotation_quaternion(), but the given basis must be orthonormalized (see Basis.orthonormalized()). Otherwise, the constructor fails and returns IDENTITY. --- tutorials/3d/using_transforms.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorials/3d/using_transforms.rst b/tutorials/3d/using_transforms.rst index df9eccd09d3..56cba0c6045 100644 --- a/tutorials/3d/using_transforms.rst +++ b/tutorials/3d/using_transforms.rst @@ -375,8 +375,8 @@ Converting a rotation to quaternion is straightforward. .. code-tab:: gdscript GDScript # Convert basis to quaternion, keep in mind scale is lost - var a = Quaternion(transform.basis) - var b = Quaternion(transform2.basis) + var a = Quaternion(transform.basis.orthonormalized()) + var b = Quaternion(transform2.basis.orthonormalized()) # Interpolate using spherical-linear interpolation (SLERP). var c = a.slerp(b,0.5) # find halfway point between a and b # Apply back @@ -385,8 +385,8 @@ Converting a rotation to quaternion is straightforward. .. code-tab:: csharp // Convert basis to quaternion, keep in mind scale is lost - var a = new Quaternion(transform.Basis); - var b = new Quaternion(transform2.Basis); + var a = new Quaternion(transform.Basis.Orthonormalized()); + var b = new Quaternion(transform2.Basis.Orthonormalized()); // Interpolate using spherical-linear interpolation (SLERP). var c = a.Slerp(b, 0.5f); // find halfway point between a and b // Apply back