Skip to content
Snippets Groups Projects
Commit c3372a8e authored by Nicola Vigano's avatar Nicola Vigano
Browse files

gtRotateVolume: added possibility to specify the rotation axis position (defaults to center)

parent 8487a5c2
No related branches found
No related tags found
No related merge requests found
function vol = gtRotateVolume(vol, rot_tensor_angle, rot_axis)
function vol = gtRotateVolume(vol, rot_tensor_angle, rot_axis, rot_center)
if (any([size(rot_tensor_angle, 1), size(rot_tensor_angle, 2)] == 1))
rot_angle = rot_tensor_angle;
if (~exist('rot_axis', 'var'))
......@@ -14,17 +14,19 @@ function vol = gtRotateVolume(vol, rot_tensor_angle, rot_axis)
rot_tensor = rot_tensor_angle;
end
[vol_size(1), vol_size(2), vol_size(3)] = size(vol);
vol_center = (vol_size + 1) / 2;
if (~exist('rot_center', 'var') || isempty(rot_center))
rot_center = (vol_size + 1) / 2;
end
T1 = eye(4);
T1(4, 1:3) = -vol_center;
T1(4, 1:3) = -rot_center;
T2 = eye(4);
T2(1:3, 1:3) = rot_tensor;
% T2(1:3, 1:3) = rot_tensor';
T3 = eye(4);
T3(4, 1:3) = +vol_center;
T3(4, 1:3) = +rot_center;
T = T1 * T2 * T3;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment