Define a function that measures the error between the position of the drawn element and the new position required by the drag action. Compute partial derivatives of this function with respect to the data variables. Minimize this function to find the new data values. Re-render everything with the new optimal data values.
It's a bit confusing, because typically what's called 'data' here would be called "parameters" in mathematical optimization, or "weights" in statistics / machine learning. Also ML would call "data" what's fixed, so here the position of the dragged element.
It's a bit confusing, because typically what's called 'data' here would be called "parameters" in mathematical optimization, or "weights" in statistics / machine learning. Also ML would call "data" what's fixed, so here the position of the dragged element.