void Fix64Test() { //Debug.LogError(fix1.ToString()); FixVector3 FA = new FixVector3(0f, 0f, 1f); FixVector3 FB = new FixVector3(1f, 0f, 0f); Fix64 Fangle = FixVector3.Angle(FA, FB); Debug.LogError(Fangle); Debug.LogError(FixVector3.Cross(FA, FB)); Debug.LogError(FixVector3.Rotate(FA, (Fix64)90)); Fix64 angleToH = (Fix64)2 * (Fix64)3.1415927 / (Fix64)360; Fix64 FangleSin = (Fix64)30 * angleToH; Debug.LogError("Fix64 sin = " + Fix64.Sin(FangleSin)); Debug.LogError("float sin = " + Mathf.Sin(30 * Mathf.Deg2Rad)); Vector3 A = new Vector3(0f, 0f, 1f); Vector3 B = new Vector3(1f, 0f, 0f); float angle = Vector3.Angle(A, B); Debug.LogError(angle); Debug.LogError(Vector3.Cross(A, B)); float dot = Vector3.Dot(A, B); Debug.LogError(Mathf.Acos(dot) + " " + Mathf.Acos(dot) * Mathf.Rad2Deg); Debug.LogError(Quaternion.AngleAxis(90, Vector3.up) * A); }
public static FixQuaternion FromToRotation(FixVector3 fromVector, FixVector3 toVector) { FixVector3 w = FixVector3.Cross(fromVector, toVector); FixQuaternion q = new FixQuaternion(w.x, w.y, w.z, FixVector3.Dot(fromVector, toVector)); q.w += Fix64.Sqrt(fromVector.SqrMagnitude * toVector.SqrMagnitude); q.Normalize(); return(q); }
public static void LookAt(FixVector3 forward, FixVector3 upwards, out FixMatrix result) { FixVector3 zaxis = forward; zaxis.Normalize(); FixVector3 xaxis = FixVector3.Cross(upwards, zaxis); xaxis.Normalize(); FixVector3 yaxis = FixVector3.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; }