Whats the source code of Quaternion.FromToRotation?

Hello,

id like to know the source code of FromToRotation, or if someone knows the FromToRotation equivalent of ue4 c++ would be better ; )

How is that relevant? That’s a pure mathematical thing. It’s probably just something along the lines:

public static Quaternion FromToRotation(Vector3 aFrom, Vector3 aTo)
{
    Vector3 axis = Vector3.Cross(aFrom, aTo);
    float angle = Vector3.Angle(aFrom, aTo);
    return Quaternion.AngleAxis(angle, axis.normalized);
}

Of course AngleAxis should be pretty straight forward as well

public static Quaternion AngleAxis(float aAngle, Vector3 aAxis)
{
    aAxis.Normalize();
    float rad = aAngle * Mathf.Deg2Rad * 0.5f;
    aAxis *= Mathf.Sin(rad);
    return new Quaternion(aAxis.x, aAxis.y, aAxis.z, Mathf.Cos(rad));
}

All untested.

@Bunny83 Thanks its working, as i mentioned i mainly search for a c++ equivalent of it but cause i havent found one ill try get the source of it to ue4 c++.