캣멀롬 스플라인 문서 원본 보기
←
캣멀롬 스플라인
둘러보기로 이동
검색으로 이동
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다:
사용자
.
문서의 원본을 보거나 복사할 수 있습니다.
{{위키데이터 속성 추적}} '''캣멀롬 스플라인'''은 [[컴퓨터 그래픽스]] 용어로, [[에드윈 캣멀]]과 Raphael Rom에 의해 정의되었다. 이는 보간 스플라인의 한 종류로서 제어점을 뚫는 모양을 가진다. <math>\mathbf{P}_0, \mathbf{P}_1, \mathbf{P}_2, \mathbf{P}_3</math> 네 개의 제어점이 주어지면 곡선은 <math>\mathbf{P}_1</math> 과 <math>\mathbf{P}_2</math> 사이에 정의된다. [[파일:Catmull-Rom_Spline.png|섬네일|캣멀롬 스플라인은 네 개의 점 사이를 보간한다]] == 정의 == [[파일:Cubic_Catmull-Rom_formulation.png|섬네일|배리와 골드만의 피라미드 공식]] [[파일:Catmull-Rom_Parameterized_Time.png|섬네일|캣멀롬 알고리즘에서의 노트 매개변수화]] 점은 <math>\mathbf{P}_i = [x_i \quad y_i]^T</math> 와 같이 표현하기로 하자. 네 개의 점 <math>\mathbf{P}_0, \mathbf{P}_1, \mathbf{P}_2, \mathbf{P}_3</math> 과 노트 <math>t_0, t_1, t_2, t_3</math> 로 정의되는 곡선 일부 \mathbf{C} 즉 캣멀롬 스플라인은 다음과 같이 표현할 수 있다 : : <math>\mathbf{C} = \frac{t_{2}-t}{t_{2}-t_1}\mathbf{B}_1+\frac{t-t_1}{t_{2}-t_1}\mathbf{B}_2</math> 이는 다음과 같다 : <math>\mathbf{B}_1 = \frac{t_{2}-t}{t_{2}-t_0}\mathbf{A}_1+\frac{t-t_0}{t_{2}-t_0}\mathbf{A}_2</math> : <math>\mathbf{B}_2 = \frac{t_{3}-t}{t_{3}-t_1}\mathbf{A}_2+\frac{t-t_1}{t_{3}-t_1}\mathbf{A}_3</math> : <math>\mathbf{A}_1 = \frac{t_{1}-t}{t_{1}-t_0}\mathbf{P}_0+\frac{t-t_0}{t_{1}-t_0}\mathbf{P}_1</math> : <math>\mathbf{A}_2 = \frac{t_{2}-t}{t_{2}-t_1}\mathbf{P}_1+\frac{t-t_1}{t_{2}-t_1}\mathbf{P}_2</math> : <math>\mathbf{A}_3 = \frac{t_{3}-t}{t_{3}-t_2}\mathbf{P}_2+\frac{t-t_2}{t_{3}-t_2}\mathbf{P}_3</math> 또한 : <math>t_{i+1} = \left[\sqrt{(x_{i+1}-x_i)^2+(y_{i+1}-y_i)^2}\right]^{\alpha} + t_i</math> 노트 매개변수화에서 <math>\alpha</math>가 0부터 1 사이의 범위를 가지고 <math>i = 0,1,2,3</math> 일 때 <math>t_0 = 0 </math> 이다. 구심적(centripetal) 캣멀롬 스플라인에서 <math>\alpha</math> 값은 <math>0.5</math>이다. <math>\alpha = 0</math> 일 때, 곡선은 표준(uniform) 캣멀롬 스플라인의 모양을 가진다. <math>\alpha = 1</math>일 때, 코달(chordal) 스플라인의 모양을 가진다. == 코드 예제 == 아래는 파이썬으로 구현한 캣멀롬 스플라인의 예제이다<syntaxhighlight lang="python"> import numpy import pylab as plt def CatmullRomSpline(P0, P1, P2, P3, nPoints=100): """ P0, P1, P2, and P3 should be (x,y) point pairs that define the Catmull-Rom spline. nPoints is the number of points to include in this curve segment. """ # Convert the points to numpy so that we can do array multiplication P0, P1, P2, P3 = map(numpy.array, [P0, P1, P2, P3]) # Calculate t0 to t4 alpha = 0.5 def tj(ti, Pi, Pj): xi, yi = Pi xj, yj = Pj return ( ( (xj-xi)**2 + (yj-yi)**2 )**0.5 )**alpha + ti t0 = 0 t1 = tj(t0, P0, P1) t2 = tj(t1, P1, P2) t3 = tj(t2, P2, P3) # Only calculate points between P1 and P2 t = numpy.linspace(t1,t2,nPoints) # Reshape so that we can multiply by the points P0 to P3 # and get a point for each value of t. t = t.reshape(len(t),1) A1 = (t1-t)/(t1-t0)*P0 + (t-t0)/(t1-t0)*P1 A2 = (t2-t)/(t2-t1)*P1 + (t-t1)/(t2-t1)*P2 A3 = (t3-t)/(t3-t2)*P2 + (t-t2)/(t3-t2)*P3 B1 = (t2-t)/(t2-t0)*A1 + (t-t0)/(t2-t0)*A2 B2 = (t3-t)/(t3-t1)*A2 + (t-t1)/(t3-t1)*A3 C = (t2-t)/(t2-t1)*B1 + (t-t1)/(t2-t1)*B2 return C def CatmullRomChain(P): """ Calculate Catmull Rom for a chain of points and return the combined curve. """ sz = len(P) # The curve C will contain an array of (x,y) points. C = [] for i in range(sz-3): c = CatmullRomSpline(P[i], P[i+1], P[i+2], P[i+3]) C.extend(c) return C # Define a set of points for curve to go through Points = [[0,1.5],[2,2],[3,1],[4,0.5],[5,1],[6,2],[7,3]] # Calculate the Catmull-Rom splines through the points c = CatmullRomChain(Points) # Convert the Catmull-Rom curve points into x and y arrays and plot x,y = zip(*c) plt.plot(x,y) # Plot the control points px, py = zip(*Points) plt.plot(px,py,'or') plt.show() </syntaxhighlight> == 같이 보기 == * [[에르미트 보간법]] == 참조 == ↑ E. Catmull and R. Rom. A class of local interpolating splines. Computer Aided Geometric Design, pages 317-326, 1974.↑ P. J. Barry and R. N. Goldman. A recursive evaluation algorithm for a class of Catmull–Rom splines. SIGGRAPH Computer Graphics, 22(4):199-204, 1988.↑ Yuksel, C.; Schaefer, S.; Keyser, J. (2011). "Parameterization and applications of Catmull-Rom curves". Computer-Aided Design 43: 747–755. ↑ Jen Hong, Tan; U. R., Acharya (2014). "Active spline model: A shape based model—interactive segmentation". Digital Signal Processing 35: 64–74. == 외부 링크 == * [http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/19283471#19283471 Implementation in Java] * [http://stackoverflow.com/a/23980479/2929337 Simplified implementation in C++] [[분류:스플라인]]
이 문서에서 사용한 틀:
틀:위키데이터 속성 추적
(
원본 보기
)
캣멀롬 스플라인
문서로 돌아갑니다.
둘러보기 메뉴
개인 도구
로그인
이름공간
문서
토론
한국어
보기
읽기
원본 보기
역사 보기
더 보기
검색
둘러보기
대문
최근 바뀜
임의의 문서로
미디어위키 도움말
특수 문서 목록
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
문서 정보