-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRF_to_Rot.m
More file actions
21 lines (21 loc) · 953 Bytes
/
RF_to_Rot.m
File metadata and controls
21 lines (21 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function [RotMat] = RF_to_Rot( RFvector )
%NAME:RF_to_Rot
%FUNCTION: Turn a RF vector into a rotation matrix
%History: written by Nick Orr druing pt II 2016-17
if sum(RFvector.^2) ~= 0
tanpsiby2 = sqrt(sum(RFvector.^2));
UV = RFvector./tanpsiby2;
sqrt(sum(UV.^2));
psi = atan(tanpsiby2) * 2;
RotMat = vrrotvec2mat([UV,psi])';
else
RotMat = eye(3);
end
%RotMat = [((UV(1)^2) * (1-cos(psi))+cos(psi)), (UV(1) * UV(2) * (1-cos(psi)) - UV(3) * sin(psi)),...
%(UV(1) * UV(3) * (1-cos(psi)) + UV(2) * sin(psi));...
%(UV(1) * UV(2) * (1-cos(psi)) + UV(3) * sin(psi)), ((UV(2)^2) * (1 - cos(psi)) + cos(psi)),...
%(UV(2) * UV(3) * (1-cos(psi)) - UV(1) * sin(psi));...
%(UV(1) * UV(3) * (1-cos(psi)) - UV(2) * sin(psi)), (UV(2) * UV(3) * (1-cos(psi)) +UV(1) * sin(psi)),...
%((UV(3)^2) * (1-cos(psi)) + cos(psi))]';
%dont know why this doesnt quite work, there might be a typo in the book
end