summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorYuri Rubinsky <chaosus89@gmail.com>2022-11-02 11:31:21 +0300
committerYuri Rubinsky <chaosus89@gmail.com>2022-11-02 11:41:32 +0300
commit9487a6ea32cb57cf0a8768cf221814c915cd8486 (patch)
tree3c6e1300376ceaca1f4f34751c18de3332880f2e /modules
parent0a0e99cadc6e250ff2ee27ef31760eb9c2e21040 (diff)
Add missed Quaternion constructor to C#
Diffstat (limited to 'modules')
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
index d459fe8c96..a80963a37e 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs
@@ -572,6 +572,30 @@ namespace Godot
}
}
+ public Quaternion(Vector3 arcFrom, Vector3 arcTo)
+ {
+ Vector3 c = arcFrom.Cross(arcTo);
+ real_t d = arcFrom.Dot(arcTo);
+
+ if (d < -1.0f + Mathf.Epsilon)
+ {
+ x = 0f;
+ y = 1f;
+ z = 0f;
+ w = 0f;
+ }
+ else
+ {
+ real_t s = Mathf.Sqrt((1.0f + d) * 2.0f);
+ real_t rs = 1.0f / s;
+
+ x = c.x * rs;
+ y = c.y * rs;
+ z = c.z * rs;
+ w = s * 0.5f;
+ }
+ }
+
/// <summary>
/// Composes these two quaternions by multiplying them together.
/// This has the effect of rotating the second quaternion