public static TSQuaternion FromToRotation(FPVector3 fromVector, FPVector3 toVector) { FPVector3 w = FPVector3.Cross(fromVector, toVector); TSQuaternion q = new TSQuaternion(w.x, w.y, w.z, FPVector3.Dot(fromVector, toVector)); q.w += FP.Sqrt(fromVector.sqrMagnitude * toVector.sqrMagnitude); q.Normalize(); return(q); }
public static void LookAt(FPVector3 forward, FPVector3 upwards, out FPMatrix result) { FPVector3 zaxis = forward; zaxis.Normalize(); FPVector3 xaxis = FPVector3.Cross(upwards, zaxis); xaxis.Normalize(); FPVector3 yaxis = FPVector3.Cross(zaxis, xaxis); result.M11 = xaxis.x; result.M21 = yaxis.x; result.M31 = zaxis.x; result.M12 = xaxis.y; result.M22 = yaxis.y; result.M32 = zaxis.y; result.M13 = xaxis.z; result.M23 = yaxis.z; result.M33 = zaxis.z; }