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
입력 인수
변환을 수행할 쿼터니언으로, quaternion
객체 또는 임의 차원의 quaternion
객체 배열로 지정됩니다.
rotationMatrix
출력값으로 표현된 회전 유형으로, "frame"
또는 "point"
로 지정됩니다.
데이터형: char
| string
출력 인수
알고리즘
쿼터니언이 다음과 같은 형식으로 주어졌을 때
프레임 회전에 상응하는 회전 행렬은 다음과 같이 정의됩니다.
점 회전에 상응하는 회전 행렬은 프레임 회전 행렬의 전치입니다.
참고 문헌
[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++ 코드를 생성할 수 있습니다.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)