Given a vector in homogeneous coordinates, `(x/z, y/z, 1)`, we define `r^2 = (x/z)^2 + (y/z)^2`. We use the simplest form of distortion function, `f(r) = 1 + k * r^2`. The distorted vector is given by `(f(r) * x/z, f(r) * y/z, 1)`.

To apply the undistortion, we need the inverse of f(r), g = f^{-1}. In this library we use the approximate formula for the undistortion function given here https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4934233/, and refine the solution using Newton-Raphson iterations (https://en.wikipedia.org/wiki/Newtons_method).

Restricting the distortion function to quadratic form allows to easily detect the cases where `r` goes beyond the monotonically-increasing range of `f` (which we refer to as overflow).

## Functions

`distortion_factor(...)`: Calculates a quadratic distortion factor given squared radii.

`undistortion_factor(...)`: Calculates the inverse quadratic distortion function given squared radii.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]