rotmat
설명
은 쿼터니언 rotationMatrix
= rotmat(quat
,rotationType
)quat
를 상응하는 회전 행렬 표현으로 변환합니다.
예제
쿼터니언을 점 회전을 위한 회전 행렬로 변환하기
점 회전에 사용할 쿼터니언을 정의합니다.
theta = 45; gamma = 30; quat = quaternion([0,theta,gamma],"eulerd","ZYX","point")
quat = quaternion
0.8924 + 0.23912i + 0.36964j + 0.099046k
쿼터니언을 회전 행렬로 변환합니다.
rotationMatrix = rotmat(quat,"point")
rotationMatrix = 3×3
0.7071 -0.0000 0.7071
0.3536 0.8660 -0.3536
-0.6124 0.5000 0.6124
회전 행렬을 확인하기 위해, y축 중심의 회전과 x축 중심의 회전에 상응하는 회전 행렬 2개를 만듭니다. 회전 행렬을 곱하고 rotmat
의 출력값과 비교합니다.
theta = 45; gamma = 30; ry = [cosd(theta) 0 sind(theta) ; ... 0 1 0 ; ... -sind(theta) 0 cosd(theta)]; rx = [1 0 0 ; ... 0 cosd(gamma) -sind(gamma) ; ... 0 sind(gamma) cosd(gamma)]; rotationMatrixVerification = rx*ry
rotationMatrixVerification = 3×3
0.7071 0 0.7071
0.3536 0.8660 -0.3536
-0.6124 0.5000 0.6124
쿼터니언을 프레임 회전을 위한 회전 행렬로 변환하기
프레임 회전에 사용할 쿼터니언을 정의합니다.
theta = 45; gamma = 30; quat = quaternion([0,theta,gamma],"eulerd","ZYX","frame")
quat = quaternion
0.8924 + 0.23912i + 0.36964j - 0.099046k
쿼터니언을 회전 행렬로 변환합니다.
rotationMatrix = rotmat(quat,"frame")
rotationMatrix = 3×3
0.7071 -0.0000 -0.7071
0.3536 0.8660 0.3536
0.6124 -0.5000 0.6124
회전 행렬을 확인하기 위해, y축 중심의 회전과 x축 중심의 회전에 상응하는 회전 행렬 2개를 만듭니다. 회전 행렬을 곱하고 rotmat
의 출력값과 비교합니다.
theta = 45; gamma = 30; ry = [cosd(theta) 0 -sind(theta) ; ... 0 1 0 ; ... sind(theta) 0 cosd(theta)]; rx = [1 0 0 ; ... 0 cosd(gamma) sind(gamma) ; ... 0 -sind(gamma) cosd(gamma)]; rotationMatrixVerification = rx*ry
rotationMatrixVerification = 3×3
0.7071 0 -0.7071
0.3536 0.8660 0.3536
0.6124 -0.5000 0.6124
쿼터니언 벡터를 회전 행렬로 변환하기
3×1 크기의 정규화된 쿼터니언 벡터를 만듭니다.
qVec = normalize(quaternion(randn(3,4)));
쿼터니언 배열을 회전 행렬로 변환합니다. rotmatArray
의 페이지는 qVec
의 선형 인덱스에 대응됩니다.
rotmatArray = rotmat(qVec,"frame");
qVec
와 rotmatArray
가 회전 시퀀스에 대응된다고 가정합니다. 쿼터니언 회전을 단일 표현으로 결합한 다음 쿼터니언 회전을 임의로 초기화된 카테시안 점에 적용합니다.
loc = normalize(randn(1,3)); quat = prod(qVec); rotateframe(quat,loc)
ans = 1×3
0.9524 0.5297 0.9013
회전 행렬을 단일 표현으로 결합한 다음 회전 행렬을 동일한 초기 카테시안 점에 적용합니다. 쿼터니언 회전과 회전 행렬의 방향이 동일한지 확인합니다.
totalRotMat = eye(3); for i = 1:size(rotmatArray,3) totalRotMat = rotmatArray(:,:,i)*totalRotMat; end totalRotMat*loc'
ans = 3×1
0.9524
0.5297
0.9013
입력 인수
quat
— 변환할 쿼터니언
quaternion
객체 | quaternion
객체로 구성된 배열
변환을 수행할 쿼터니언으로, quaternion
객체 또는 임의 차원의 quaternion
객체 배열로 지정됩니다.
rotationType
— 회전 유형
"frame"
| "point"
rotationMatrix
출력값으로 표현된 회전 유형으로, "frame"
또는 "point"
로 지정됩니다.
데이터형: char
| string
출력 인수
rotationMatrix
— 회전 행렬 표현
3×3 숫자형 행렬 | 3×3×N 숫자형 배열
회전 행렬 표현으로, 3×3 숫자형 행렬 또는 3×3×N 숫자형 배열로 반환됩니다.
quat
가 스칼라이면,rotationMatrix
는 3×3 행렬로 반환됩니다.quat
가 스칼라가 아니면,rotationMatrix
는 3×3×N 배열로 반환됩니다. 여기서rotationMatrix(:,:,i)
는quat(i)
에 대응되는 회전 행렬입니다.
회전 행렬의 데이터형은 quat
의 기본 데이터형과 같습니다.
데이터형: single
| double
알고리즘
쿼터니언이 다음과 같은 형식으로 주어졌을 때
프레임 회전에 상응하는 회전 행렬은 다음과 같이 정의됩니다.
점 회전에 상응하는 회전 행렬은 프레임 회전 행렬의 전치입니다.
참고 문헌
[1] Kuipers, Jack B. Quaternions and Rotation Sequences: A Primer with Applications to Orbits, Aerospace, and Virtual Reality. Princeton, NJ: Princeton University Press, 2007.
확장 기능
C/C++ 코드 생성
MATLAB® Coder™를 사용하여 C 코드나 C++ 코드를 생성할 수 있습니다.
버전 내역
R2019b에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)