x, y fitting , 1차 다항식
import numpy as np
x = [1., 2., 3., 4., 5.]
y = [0.8, 2.2, 3.1, 3.9 5.1]
x = np.array(x)
y = np.array(y)
order = 1
yfit = np.polyfit(x,y,order)
x,y 를 z 에 맞춤, 2차 다항식
import warnings
from astropy.modeling import models, fitting
x = [1., 1., 1., 2., 2., 2., 3., 3., 3.]
y = [1., 2., 3., 1., 2., 3., 1., 2., 3.]
z = [-0.05, 0.45, -0.1, 0.51, 1.05, 0.48, 0.0, 0.5, 0.01]
order = 2
p_init = models.Polynomial2D(degree=order)
fit_p = fitting.LevMarLSQFitter()
with warnings.catch_warnings():
warnings.simplefilter('ignore')
model = fit_p(p_init, x, y, z)
xmin = min(x)
xmax = max(x)
ymin = min(y)
ymax = max(y)
dx = 0.05
dy = 0.05
xtmp = np.arange(xmin-dx, xmax+dx, dx)
ytmp = np.arange(ymin-dy, ymax+dy, dy)
xfit, yfit = np.meshgrid(xtmp,ytmp)
zfit = model(xfit,yfit)
coeff = model.parameters
출처 : https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=seul4ever1&logNo=221650777702
'Autonomous Vehicle' 카테고리의 다른 글
Polynomial Line Fitting Removing Outliers Using RANSAC (Python Code) (0) | 2021.11.15 |
---|---|
오일러각(angle) 쿼터니언(x, y, z, w) 변환 (Python Code) (0) | 2021.11.10 |
ZED F9P with RTK - WGS to UTM (0) | 2021.11.09 |
Docker exec 명령어 : 외장그래픽 연결, 디스플레이 연결, 폴더 공유 설정 (0) | 2021.10.21 |
Docker 도커 이미지, 컨테이너 백업하고 삭제하는 방법 (0) | 2021.10.12 |