-
Notifications
You must be signed in to change notification settings - Fork 0
/
addNoise.m
33 lines (26 loc) · 841 Bytes
/
addNoise.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function R_new = addNoise(R,noiseVar,noisePosition, noiseType)
% R : SO(3)
% noiseVar : noise variance (radian)
% noisePosition : 0-left, 1-right
if noiseType == 'G'
if strcmp(noisePosition, 'left')
R_new = LargeSO3(randn(3,1)*noiseVar)*R;
elseif strcmp(noisePosition, 'right')
R_new = R*LargeSO3(randn(3,1)*noiseVar);
else
error('Check noise position.');
end
elseif noiseType == 'U'
w = randn(3,1);
w = w/norm(w);
if strcmp(noisePosition, 'left')
R_new = LargeSO3(w*noiseVar*rand)*R;
elseif strcmp(noisePosition, 'right')
R_new = R*LargeSO3(w*noiseVar*rand);
else
error('Check noise position.');
end
else
error('Check noise type.');
end
end