Skip to content

Commit

Permalink
#103022 reimplement Vector3.SignedAngleTo
Browse files Browse the repository at this point in the history
  • Loading branch information
markdchurchill committed Feb 25, 2025
1 parent 14964cc commit d5e9f5a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,10 @@ public readonly Vector3 Sign()
/// <returns>The signed angle between the two vectors, in radians.</returns>
public readonly real_t SignedAngleTo(Vector3 to, Vector3 axis)
{
Vector3 crossTo = Cross(to);
real_t unsignedAngle = Mathf.Atan2(crossTo.Length(), Dot(to));
real_t sign = crossTo.Dot(axis);
return (sign < 0) ? -unsignedAngle : unsignedAngle;
var axisNorm = axis.Normalized();
var vY = axis.Cross(this);
var vX = vY.Cross(axisNorm);
return Mathf.Atan2(to.Dot(vY), to.Dot(vX));
}

/// <summary>
Expand Down

0 comments on commit d5e9f5a

Please sign in to comment.