Frequently BSpline surfaces failed to lower points to 2D because of the use of try_inverse() to compute the gradient delta_i - this is because using this method, if you arrive at a stationary point, J_i stops being invertible.
The solution here uses the pseudo inverse, which basically resolves to [0 0; 0 0], making delta_i = 0 (as expected), rather than returning None.
Another option would be to simply set delta_i = 0 when try_inverse is None, however the psuedo-inverse is preffered because it sets only the singular values below epsilon (chosen arbitrarily here to 1e-4) of the inverted matrix to 0. This typically results in the 0 matrix, maybe there are times when it doesn't and you'd stop prematurely, I couldn't tell you for certain if that ever happens, can't hurt though...
Frequently BSpline surfaces failed to lower points to 2D because of the use of try_inverse() to compute the gradient
delta_i
- this is because using this method, if you arrive at a stationary point,J_i
stops being invertible.The solution here uses the pseudo inverse, which basically resolves to [0 0; 0 0], making delta_i = 0 (as expected), rather than returning None.
Another option would be to simply set delta_i = 0 when try_inverse is
None
, however the psuedo-inverse is preffered because it sets only the singular values below epsilon (chosen arbitrarily here to1e-4
) of the inverted matrix to 0. This typically results in the 0 matrix, maybe there are times when it doesn't and you'd stop prematurely, I couldn't tell you for certain if that ever happens, can't hurt though...