2018-07-23 21:47:50 +00:00
|
|
|
function d = DistanceToSO3(mat)
|
|
|
|
|
% *** CHAPTER 3: RIGID-BODY MOTIONS ***
|
2018-07-23 08:17:51 +00:00
|
|
|
% Takes mat: A 3x3 matrix.
|
2018-07-23 21:47:50 +00:00
|
|
|
% Returns the Frobenius norm to describe the distance of mat from the SO(3)
|
2018-07-23 08:17:51 +00:00
|
|
|
% manifold.
|
|
|
|
|
% Computes the distance from R to the SO(3) manifold using the following
|
|
|
|
|
% method:
|
2018-07-23 21:47:50 +00:00
|
|
|
% If det(mat) <= 0, return a large number.
|
|
|
|
|
% If det(mat) > 0, return norm(mat' * mat - I).
|
2018-07-23 08:17:51 +00:00
|
|
|
% Example Inputs:
|
2018-07-23 21:47:50 +00:00
|
|
|
%
|
|
|
|
|
% clear; clc;
|
|
|
|
|
% mat = [1.0, 0.0, 0.0;
|
|
|
|
|
% 0.0, 0.1, -0.95;
|
|
|
|
|
% 0.0, 1.0, 0.1];
|
|
|
|
|
% d = DistanceToSO3(mat)
|
|
|
|
|
%
|
2018-07-23 08:17:51 +00:00
|
|
|
% Output:
|
|
|
|
|
% d =
|
|
|
|
|
% 0.0884
|
|
|
|
|
|
2018-07-23 21:47:50 +00:00
|
|
|
if det(mat) > 0
|
|
|
|
|
d = norm(mat' * mat - eye(3), 'fro');
|
2018-07-23 08:17:51 +00:00
|
|
|
else
|
|
|
|
|
d = 1e+9;
|
|
|
|
|
end
|
|
|
|
|
end
|