public FixVector3 GetNormalized() { FixVector3 v = new FixVector3(this); v.Normalize(); return(v); }
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; }
public static FixQuaternion AngleAxis(Fix64 angle, FixVector3 axis) { axis = axis * Fix64.Deg2Rad; axis.Normalize(); Fix64 halfAngle = angle * Fix64.Deg2Rad * Fix64.Half; FixQuaternion rotation; Fix64 sin = Fix64.Sin(halfAngle); rotation.x = axis.x * sin; rotation.y = axis.y * sin; rotation.z = axis.z * sin; rotation.w = Fix64.Cos(halfAngle); return(rotation); }