Skip to content
GitLab
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
7ba91408
Commit
7ba91408
authored
Jun 30, 2020
by
Jean-Yves TINEVEZ
Browse files
Change the input of functions.
Now we work more like a class with methods.
parent
49028dd1
Changes
3
Hide whitespace changes
Inline
Side-by-side
RunExample.m
View file @
7ba91408
...
...
@@ -146,15 +146,15 @@ for i = 1 : n_objects
o
=
objects
(
i
);
area
=
area3d
(
o
.
boundary
);
perim
=
perimeter3d
(
o
.
boundary
);
[
area
,
uncorr_area
]
=
area3d
(
o
);
[
perim
,
uncorr_perim
]
=
perimeter3d
(
o
);
objects
(
i
)
.
area
=
area
;
objects
(
i
)
.
perimeter
=
perim
;
uncorr
=
struct
();
uncorr
.
area
=
polyarea
(
o
.
boundary
(:,
1
),
o
.
boundary
(:,
2
)
)
;
uncorr
.
perimeter
=
perimeter3d
(
o
.
boundary
(
:,
1
:
2
)
)
;
uncorr
.
area
=
uncorr_area
;
uncorr
.
perimeter
=
uncorr_perim
;
objects
(
i
)
.
uncorr
=
uncorr
;
end
...
...
src/area3d.m
View file @
7ba91408
function
area
=
area3d
(
p
)
%AREA3D Computes the area of a 3D closed polygon.
% p must be a Nx3 matrix.
function
[
area
,
uncorr_area
]
=
area3d
(
o
)
%AREA3D Computes the area of the object.
%% Deprojected 3D version.
p
=
o
.
boundary
;
n_vertices
=
size
(
p
,
1
);
...
...
@@ -25,7 +28,14 @@ function area = area3d( p )
% Total positive area.
area
=
sum
(
area_triangle
)
/
2
;
%% 2D area.
uncorr_area
=
polyarea
(
o
.
boundary
(:,
1
),
o
.
boundary
(:,
2
)
);
%% Subfunction.
function
n
=
euclidean_norm
(
v
)
n
=
sqrt
(
sum
(
v
.*
v
,
ndims
(
v
)
)
);
end
...
...
src/perimeter3d.m
View file @
7ba91408
function
perim
=
perimeter3d
(
p
)
function
[
perim
,
uncorr_perim
]
=
perimeter3d
(
o
)
%PERIMETER3D Perimeter of a closed N-dimensional polygon.
% p can be a N x d matrix, with d being the dimensionality.
p
2
=
[
p
;
p
(
1
,
:
)
]
;
p_diff
=
diff
(
p2
);
p
erim
=
compute_perim
(
o
.
boundary
)
;
uncorr_perim
=
compute_perim
(
o
.
boundary
(
:
,
1
:
2
)
);
p_diff_2
=
p_diff
.*
p_diff
;
p_diff_2_sum
=
sum
(
p_diff_2
,
2
);
sls
=
sqrt
(
p_diff_2_sum
);
perim
=
sum
(
sls
);
%% Subfunction
function
l_perim
=
compute_perim
(
p
)
% p can be a N x d matrix, with d being the dimensionality.
p2
=
[
p
;
p
(
1
,
:
)
];
p_diff
=
diff
(
p2
);
p_diff_2
=
p_diff
.*
p_diff
;
p_diff_2_sum
=
sum
(
p_diff_2
,
2
);
sls
=
sqrt
(
p_diff_2_sum
);
l_perim
=
sum
(
sls
);
end
end
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment