/// <summary> /// Solve A * x = b, where b is a column vector. This is more efficient /// than computing the inverse in one-shot cases. /// </summary> /// <param name="b">The b.</param> /// <returns></returns> public FVector3 Solve33(FVector3 b) { float det = FVector3.Dot(ex, FVector3.Cross(ey, ez)); if (det != 0.0f) { det = 1.0f / det; } return(new FVector3(det * FVector3.Dot(b, FVector3.Cross(ey, ez)), det * FVector3.Dot(ex, FVector3.Cross(b, ez)), det * FVector3.Dot(ex, FVector3.Cross(ey, b)))); }
public static void CreateLookAt(ref FVector3 cameraPosition, ref FVector3 cameraTarget, ref FVector3 cameraUpVector, out FMatrix result) { // http://msdn.microsoft.com/en-us/library/bb205343(v=VS.85).aspx FVector3 vz = FVector3.Normalize(cameraPosition - cameraTarget); FVector3 vx = FVector3.Normalize(FVector3.Cross(cameraUpVector, vz)); FVector3 vy = FVector3.Cross(vz, vx); result = Identity; result.M11 = vx.X; result.M12 = vy.X; result.M13 = vz.X; result.M21 = vx.Y; result.M22 = vy.Y; result.M23 = vz.Y; result.M31 = vx.Z; result.M32 = vy.Z; result.M33 = vz.Z; result.M41 = -FVector3.Dot(vx, cameraPosition); result.M42 = -FVector3.Dot(vy, cameraPosition); result.M43 = -FVector3.Dot(vz, cameraPosition); }