Silk.NET icon indicating copy to clipboard operation
Silk.NET copied to clipboard

Start of rotate vector by quaternion with multiplication operator

Open qhdwight opened this issue 3 years ago • 6 comments

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)

qhdwight avatar Feb 11 '22 22:02 qhdwight

CLA assistant check
All CLA requirements met.

dnfadmin avatar Feb 11 '22 22:02 dnfadmin

We'll be happy to accept this if you're still willing to contribute it! I notice there hasn't been any commits yet.

Perksey avatar Feb 20 '22 14:02 Perksey

Oops been a bit busy, will try to make some commits this weekend

qhdwight avatar Feb 26 '22 00:02 qhdwight

What else should I add, public interface, unit testing?

qhdwight avatar Feb 27 '22 23:02 qhdwight

Adding unit testing to the test project would be much appreciated

HurricanKai avatar Feb 28 '22 05:02 HurricanKai

Has there been any update on this? @HurricanKai this has been open for a while, how much do you care about the unit testing?

Perksey avatar May 13 '22 18:05 Perksey

bump @HurricanKai do we merge without testing or close for inactivity?

Perksey avatar Nov 03 '22 12:11 Perksey

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.

HurricanKai avatar Nov 03 '22 12:11 HurricanKai