Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
66288861
Commit
66288861
authored
6 years ago
by
Wolfgang Ludwig
Browse files
Options
Downloads
Patches
Plain Diff
bugfix by Yohann
Signed-off-by:
Wolfgang Ludwig
<
wolfgang.ludwig@esrf.fr
>
parent
b4d3a87a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zUtil_Maths/gtMathsRod2Euler.m
+52
-49
52 additions, 49 deletions
zUtil_Maths/gtMathsRod2Euler.m
with
52 additions
and
49 deletions
zUtil_Maths/gtMathsRod2Euler.m
100644 → 100755
+
52
−
49
View file @
66288861
function
euler
=
gtMathsRod2Euler
(
r
)
% GTMATHSROD2EULER Convert Rodrigues vectors to Euler angles (in degrees).
% These follow Bunge convention (ZXZ) [phi1; phi; phi2].
%
% euler = gtMathsRod2Euler(r)
% -------------------------------------------------------------------------
%
% INPUT:
% r = <double> Rodrigues vectors, as column vectors (3xN array).
%
% OUTPUT:
% euler = <double> Euler angles triplets, as column vectors (3xN array).
% Output angles are in degrees and only positive.
%
% Version 002 17-10-2012 by YGuilhem
% Vectorize function to process quickly lots of Rogrigues vectors
%
% Version 001 15-06-2012 by YGuilhem
% Check size of r column vectors
if
size
(
r
,
1
)
~=
3
gtError
(
'Rodrigues:wrong_input_size'
,
...
'Input array r should be sized 3xN!'
);
end
% Set epsilon to avoid singular values
epsilon
=
1.e-9
;
% Build regular filters
regular
=
r
>=
epsilon
;
regular_a
=
regular
(
1
,
:)
&
regular
(
2
,
:);
regular_b
=
regular
(
3
,
:);
% conpute intermediate values
a
=
double
(
~
regular_a
)
.*
pi
/
4
+
double
(
regular_a
)
.*
atan2
(
r
(
2
,
:),
r
(
1
,
:));
b
=
double
(
~
regular_b
)
.*
pi
/
4
+
double
(
regular_b
)
.*
atan
(
r
(
3
,
:));
% Compute Euler angles in radians
phi1
=
a
+
b
;
phi
=
2
*
atan2
(
sqrt
(
r
(
1
,
:)
.^
2
+
r
(
2
,
:)
.^
2
),
sqrt
(
1.
+
r
(
3
,
:)
.^
2
));
phi2
=
b
-
a
;
% Switch to degrees
euler
=
[
phi1
;
phi
;
phi2
]
*
180
/
pi
;
% Shift to positive angles range
euler
=
mod
(
euler
,
360.
);
end
% end of function
function
euler
=
gtMathsRod2Euler
(
r
)
% GTMATHSROD2EULER Convert Rodrigues vectors to Euler angles (in degrees).
% These follow Bunge convention (ZXZ) [phi1; phi; phi2].
%
% euler = gtMathsRod2Euler(r)
% -------------------------------------------------------------------------
%
% INPUT:
% r = <double> Rodrigues vectors, as column vectors (3xN array).
%
% OUTPUT:
% euler = <double> Euler angles triplets, as column vectors (3xN array).
% Output angles are in degrees and only positive.
%
% Version 002 17-10-2012 by YGuilhem
% Vectorize function to process quickly lots of Rogrigues vectors
%
% Version 001 15-06-2012 by YGuilhem
% Check size of r column vectors
if
size
(
r
,
1
)
~=
3
gtError
(
'Rodrigues:wrong_input_size'
,
...
'Input array r should be sized 3xN!'
);
end
% Set epsilon to avoid singular values
epsilon
=
1.e-9
;
% Compute first intermediate value
c
=
cos
(
atan
(
sqrt
(
sum
(
r
.^
2
))));
% Build regular filters
regular
=
abs
(
c
.*
r
)
>=
epsilon
;
regular_a
=
regular
(
1
,
:)
|
regular
(
2
,
:);
regular_b
=
regular
(
3
,
:)
|
c
>=
epsilon
;
% Compute second intermediate values
a
=
double
(
~
regular_a
)
.*
pi
/
4
+
double
(
regular_a
)
.*
atan2
(
r
(
2
,
:),
r
(
1
,
:));
b
=
double
(
~
regular_b
)
.*
pi
/
4
+
double
(
regular_b
)
.*
atan2
(
r
(
3
,
:),
1.
);
% Compute Euler angles in radians
phi1
=
a
+
b
;
phi
=
2
*
atan2
(
sqrt
(
r
(
1
,
:)
.^
2
+
r
(
2
,
:)
.^
2
),
sqrt
(
1.
+
r
(
3
,
:)
.^
2
));
phi2
=
b
-
a
;
% Switch to degrees
euler
=
[
phi1
;
phi
;
phi2
]
*
180
/
pi
;
% Shift to positive angles range
euler
=
mod
(
euler
,
360.
);
end
% end of function
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment