Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IAH public
DeProj
Commits
9d5a498d
Commit
9d5a498d
authored
Jul 07, 2020
by
Jean-Yves TINEVEZ
Browse files
Rework the ellipse plotting routines.
parent
9e532f94
Changes
4
Show whitespace changes
Inline
Side-by-side
src/@epicell/epicell.m
View file @
9d5a498d
...
...
@@ -84,6 +84,16 @@ classdef epicell
'LineWidth'
,
1
,
...
'Marker'
,
'.'
);
end
% Plot a 2D ellipse in 3D.
h
=
plot_ellipse_3d
(
obj
,
npoints
,
ax
)
% Plot an ellipse in XY plane.
h
=
plot_ellipse_2d
(
obj
,
npoints
,
ax
)
% Generate 3D points on the ellipse fit.
p
=
get_ellipse_points
(
obj
,
npoints
)
end
%% Private static methods: compute final properties value.
...
...
@@ -203,12 +213,6 @@ classdef epicell
% Fit a 2D ellipse to a set of 3D points.
[
f3d
,
v
]
=
fit_ellipse_3d
(
p
,
E
,
method
)
% Plot a 2D ellipse in 3D.
h
=
plot_ellipse_3d
(
f3d
,
v
,
npoints
)
% Plot an ellipse in XY plane.
h
=
plot_ellipse_2d
(
f
,
npoints
)
end
end
src/@epicell/get_ellipse_points.m
0 → 100644
View file @
9d5a498d
function
p
=
get_ellipse_points
(
obj
,
npoints
)
%GET_ELLIPSE_POINTS Generate 3D points on the ellipse fit.
f
=
obj
.
ellipse_fit
;
v
=
epicell
.
euleurZXZ2rot
(
obj
.
euler_angles
);
x0
=
f
(
1
);
y0
=
f
(
2
);
z0
=
f
(
3
);
a
=
f
(
4
);
b
=
f
(
5
);
theta
=
f
(
6
);
R
=
[
cos
(
theta
)
sin
(
theta
)
;
-
sin
(
theta
)
cos
(
theta
)
]
;
t
=
linspace
(
0.5
*
pi
,
2.5
*
pi
,
npoints
)
'
;
XY0
=
[
a
*
sin
(
t
),
b
*
cos
(
t
)
];
XY1
=
XY0
*
R
;
xr
=
XY1
(
:,
1
);
yr
=
XY1
(
:,
2
);
zr
=
zeros
(
numel
(
xr
),
1
);
pr
=
[
xr
yr
zr
];
% Transform back
pb
=
pr
*
v
'
;
xb
=
pb
(
:,
1
)
+
x0
;
yb
=
pb
(
:,
2
)
+
y0
;
zb
=
pb
(
:,
3
)
+
z0
;
xb
=
[
xb
;
xb
(
1
,:)
];
yb
=
[
yb
;
yb
(
1
,:)
];
zb
=
[
zb
;
zb
(
1
,:)
];
p
=
[
xb
,
yb
,
zb
];
end
src/@epicell/plot_ellipse_2d.m
View file @
9d5a498d
function
h
=
plot_ellipse_2d
(
f
,
npoints
)
%PLOT_ELLIPSE_2D Plot
an
ellipse
in
XY plane.
function
h
=
plot_ellipse_2d
(
obj
,
npoints
,
ax
)
%PLOT_ELLIPSE_2D Plot
the
ellipse
projected on the
XY plane.
if
nargin
<
2
npoints
=
20
;
end
p
=
get_ellipse_points
(
obj
,
npoints
);
x0
=
f
(
1
);
y0
=
f
(
2
);
a
=
f
(
3
);
b
=
f
(
4
);
theta
=
f
(
5
);
xb
=
p
(
:,
1
);
yb
=
p
(
:,
2
);
R
=
[
cos
(
theta
)
sin
(
theta
)
;
-
sin
(
theta
)
cos
(
theta
)
]
;
t
=
linspace
(
0
,
2
*
pi
,
npoints
)
'
;
XY0
=
[
a
*
sin
(
t
),
b
*
cos
(
t
)
];
XY1
=
XY0
*
R
;
xr
=
XY1
(
:,
1
)
+
x0
;
yr
=
XY1
(
:,
2
)
+
y0
;
xr
=
[
xr
;
xr
(
1
,:)
];
yr
=
[
yr
;
yr
(
1
,:)
];
h
=
line
(
xr
,
yr
);
xb
=
[
xb
;
xb
(
1
,:)
];
yb
=
[
yb
;
yb
(
1
,:)
];
h
=
line
(
ax
,
xb
,
yb
);
end
src/@epicell/plot_ellipse_3d.m
View file @
9d5a498d
function
h
=
plot_ellipse_3d
(
f3d
,
v
,
npoints
)
function
h
=
plot_ellipse_3d
(
obj
,
npoints
,
ax
)
%PLOT_ELLIPSE_3D Plot a 2D ellipse in 3D.
if
nargin
<
3
npoints
=
20
;
end
p
=
get_ellipse_points
(
obj
,
npoints
);
x0
=
f3d
(
1
);
y0
=
f3d
(
2
);
z0
=
f3d
(
3
);
a
=
f3d
(
4
);
b
=
f3d
(
5
);
theta
=
f3d
(
6
);
R
=
[
cos
(
theta
)
sin
(
theta
)
;
-
sin
(
theta
)
cos
(
theta
)
]
;
t
=
linspace
(
0
,
2
*
pi
,
npoints
)
'
;
XY0
=
[
a
*
sin
(
t
),
b
*
cos
(
t
)
];
XY1
=
XY0
*
R
;
xr
=
XY1
(
:,
1
);
yr
=
XY1
(
:,
2
);
zr
=
zeros
(
numel
(
xr
),
1
);
pr
=
[
xr
yr
zr
];
% Transform back
pb
=
pr
*
v
'
;
xb
=
pb
(
:,
1
)
+
x0
;
yb
=
pb
(
:,
2
)
+
y0
;
zb
=
pb
(
:,
3
)
+
z0
;
xb
=
p
(
:,
1
);
yb
=
p
(
:,
2
);
zb
=
p
(
:,
3
);
xb
=
[
xb
;
xb
(
1
,:)
];
yb
=
[
yb
;
yb
(
1
,:)
];
zb
=
[
zb
;
zb
(
1
,:)
];
h
=
line
(
xb
,
yb
,
zb
);
h
=
line
(
ax
,
xb
,
yb
,
zb
);
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment