summaryrefslogtreecommitdiff
path: root/modules/mono/glue
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2020-10-06 15:43:47 -0400
committerAaron Franke <arnfranke@yahoo.com>2020-10-06 15:57:47 -0400
commitbea7d61fd9d9cafa43cdc313780257eea09a190b (patch)
tree764662a4539de501e24fdbc97e3580f533a7ba7c /modules/mono/glue
parent07112b92a85de9b2134f3208149b295f871d3642 (diff)
Improve the Vector2 rotated code in C#
Diffstat (limited to 'modules/mono/glue')
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
index 3dff37279b..d536b14eac 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs
@@ -437,8 +437,11 @@ namespace Godot
/// <returns>The rotated vector.</returns>
public Vector2 Rotated(real_t phi)
{
- real_t rads = Angle() + phi;
- return new Vector2(Mathf.Cos(rads), Mathf.Sin(rads)) * Length();
+ real_t sine = Mathf.Sin(phi);
+ real_t cosi = Mathf.Cos(phi);
+ return new Vector2(
+ x * cosi - y * sine,
+ x * sine + y * cosi);
}
/// <summary>