我正试图使用非球面镜片配方将一个9点的云调到圆锥形:
z(r)=r²/(R*(1 + sqrt(1-(1 + K)*(r²/R²))))
其中R是曲率半径,K是圆锥常数和r = sqrt(x²+y²).K保持不变(已知值),R正是我正在寻找的.我从http://wiki.scipy.org/Cookbook/Least_Squares_Circle开始在python中编写它.我用于圆锥曲线的隐式形式是r² - 2.R.Z + (1+K).Z²
这就是我写的:
# -*- coding: cp1252 -*-
from scipy import odr
from numpy import *
# Coordinates of the 3D points
X = [ 0, 1, -1, 0, 0, 0.5, -0.5, 0, 0 ]
Y = [ 0, 0, 0, 1, -1, 0, 0, 0.5, -0.5 ]
Z = [ 0, 0.113696489, 0.113696489, 0.113696489, 0.113696489, 0.027933838, 0.027933838, 0.027933838, 0.027933838]
#constantes
Rc = 8 …Run Code Online (Sandbox Code Playgroud)