Silk.NET
Silk.NET copied to clipboard
Start of rotate vector by quaternion with multiplication operator
Summary of the PR
Adds the ability to "multiply" a vector by a quaternion, effectively rotating it. This is supported by Unity.
Mock implementation (no operator signature yet):
public static Vector3D<double> Rotate(in Vector3D<double> v, in Quaternion<double> q)
{
Debug.Assert(Math.Abs(q.LengthSquared() - 1.0) < 1e-6f);
var u = new Vector3D<double>(q.X, q.Y, q.Z);
double s = q.W;
return 2.0 * Vector3D.Dot(u, v) * u
+ (s * s - Vector3D.Dot(u, u)) * v
+ 2.0 * s * Vector3D.Cross(u, v);
}
Related issues, Discord discussions, or proposals
https://gamedev.stackexchange.com/questions/28395/rotating-vector3-by-a-quaternion
Further Comments
I was looking for a builtin function, couldn't seem to find it (or wasn't obvious)
We'll be happy to accept this if you're still willing to contribute it! I notice there hasn't been any commits yet.
Oops been a bit busy, will try to make some commits this weekend
What else should I add, public interface, unit testing?
Adding unit testing to the test project would be much appreciated
Has there been any update on this? @HurricanKai this has been open for a while, how much do you care about the unit testing?
bump @HurricanKai do we merge without testing or close for inactivity?
I don't have the time to verify or add the remaining function signatures. Closing for inactivity. Feel free to reopen or start a new PR.