From 722dc5d2bfb027f18fc8b225c5950c482f614659 Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Fri, 12 Feb 2016 11:52:35 +0100 Subject: [PATCH] Add closed-form expression of the inverse stereographic projection --- problems/inverse-stereographic-projection.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 problems/inverse-stereographic-projection.py diff --git a/problems/inverse-stereographic-projection.py b/problems/inverse-stereographic-projection.py new file mode 100644 index 00000000..703ffa71 --- /dev/null +++ b/problems/inverse-stereographic-projection.py @@ -0,0 +1,17 @@ +# The inverse stereographic projection through the north pole, and its derivative +def f(x): + normSquared = x[0]*x[0]+x[1]*x[1] + return [2*x[0] / (normSquared+1), 2*x[1] / (normSquared+1), (normSquared-1)/ (normSquared+1)] + #a = 20 + #normSquared = a*a*(x[0]*x[0]+x[1]*x[1]) + #return [a*2*x[0] / (normSquared+1), a*2*x[1] / (normSquared+1), (normSquared-1)/ (normSquared+1)] + +def df(x): + normSquared = x[0]*x[0]+x[1]*x[1] + denominator = (1+normSquared)*(1+normSquared) + + return (( (2*(1+normSquared) - 4*x[0]*x[0]) / denominator, (-4*x[0]*x[1]) / denominator), + ( (-4*x[1]*x[0]) / denominator, (2*(1+normSquared) - 4*x[1]*x[1]) / denominator), + (4*x[0]/denominator,4*x[1]/denominator)) + +fdf = (f, df) -- GitLab