Skip to content

Commit

Permalink
Coherent faces orientation + rename
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDouillet committed Aug 25, 2023
1 parent fe952ab commit 8e163c6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 54 deletions.
29 changes: 16 additions & 13 deletions doc.m
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
%% meshed_ovoid
%% mesh_ovoid
%
% Function to compute, display, and save a meshed ovoid.
%
% Author & support : nicolas.douillet (at) free.fr, 2020.
% Author & support : nicolas.douillet (at) free.fr, 2020-2023.
%
%% Syntax
%
% meshed_ovoid;
% mesh_ovoid;
%
% meshed_ovoid(nb_samples);
% mesh_ovoid(nb_samples);
%
% meshed_ovoid(nb_samples, option_display);
% mesh_ovoid(nb_samples, option_display);
%
% [V,T] = meshed_ovoid(nb_samples, option_display);
% [V,T] = mesh_ovoid(nb_samples, option_display);
%
%% Description
%
% meshed_ovoid compute and display a meshed ovoid made of 64 samples
% mesh_ovoid compute and display a meshed ovoid made of 64 samples
% in longitude angle and 64 samples in latitude angle. The radius of
% the bottom half sphere equals 1.
%
% meshed_ovoid(nb_samples) uses nb_samples for a half pi angle.
% mesh_ovoid(nb_samples) uses nb_samples for a half pi angle.
%
% meshed_ovoid(nb_samples, option_display) displays the result
% mesh_ovoid(nb_samples, option_display) displays the result
% when option_display is set to logical *true/*1 and doesn't when it is
% set to logical false/0.
%
% [V,T] = meshed_ovoid(nb_samples, option_display) stores the resulting
% [V,T] = mesh_ovoid(nb_samples, option_display) stores the resulting
% vertices coordinates in the array V, and the corresponding triplet
% indices list in the array T.
%
%% See also
%
% <https://fr.mathworks.com/help/matlab/ref/sphere.html sphere> |
% <https://fr.mathworks.com/help/matlab/ref/ellipsoid.html ellipsoid> |
% | <https://fr.mathworks.com/matlabcentral/fileexchange/85173-mesh-generation-toolbox mesh generation toolbox> |
% <https://fr.mathworks.com/matlabcentral/fileexchange/77004-mesh-processing-toolbox?s_tid=srchtitle
% mesh processing toolbox> |
% <https://fr.mathworks.com/help/matlab/ref/sphere.html sphere> |
% <https://fr.mathworks.com/help/matlab/ref/ellipsoid.html ellipsoid> |
%
%% Input arguments
%
Expand All @@ -54,4 +57,4 @@
%% Example
% With default parameter values

meshed_ovoid;
mesh_ovoid;
35 changes: 19 additions & 16 deletions html/doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
--><title>meshed_ovoid</title><meta name="generator" content="MATLAB 9.7"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2020-12-04"><meta name="DC.source" content="doc.m"><style type="text/css">
--><title>mesh_ovoid</title><meta name="generator" content="MATLAB 9.7"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2023-08-25"><meta name="DC.source" content="doc.m"><style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}

html { min-height:100%; margin-bottom:1px; }
Expand Down Expand Up @@ -66,49 +66,52 @@



</style></head><body><div class="content"><h1>meshed_ovoid</h1><!--introduction--><p>Function to compute, display, and save a meshed ovoid.</p><p>Author &amp; support : nicolas.douillet (at) free.fr, 2020.</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Syntax</a></li><li><a href="#2">Description</a></li><li><a href="#3">See also</a></li><li><a href="#4">Input arguments</a></li><li><a href="#5">Output arguments</a></li><li><a href="#6">Example</a></li></ul></div><h2 id="1">Syntax</h2><p>meshed_ovoid;</p><p>meshed_ovoid(nb_samples);</p><p>meshed_ovoid(nb_samples, option_display);</p><p>[V,T] = meshed_ovoid(nb_samples, option_display);</p><h2 id="2">Description</h2><p>meshed_ovoid compute and display a meshed ovoid made of 64 samples in longitude angle and 64 samples in latitude angle. The radius of the bottom half sphere equals 1.</p><p>meshed_ovoid(nb_samples) uses nb_samples for a half pi angle.</p><p>meshed_ovoid(nb_samples, option_display) displays the result when option_display is set to logical *true/*1 and doesn't when it is set to logical false/0.</p><p>[V,T] = meshed_ovoid(nb_samples, option_display) stores the resulting vertices coordinates in the array V, and the corresponding triplet indices list in the array T.</p><h2 id="3">See also</h2><p><a href="https://fr.mathworks.com/help/matlab/ref/sphere.html">sphere</a> | <a href="https://fr.mathworks.com/help/matlab/ref/ellipsoid.html">ellipsoid</a> |</p><h2 id="4">Input arguments</h2><p>- nb_samples : positive integer double, nb_samples &gt; 2, the number of samples for 0.5*pi angle.</p><p>- option_display : either logical *true/false or numeric 1/0.</p><h2 id="5">Output arguments</h2><pre> [ | | |]
</style></head><body><div class="content"><h1>mesh_ovoid</h1><!--introduction--><p>Function to compute, display, and save a meshed ovoid.</p><p>Author &amp; support : nicolas.douillet (at) free.fr, 2020-2023.</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Syntax</a></li><li><a href="#2">Description</a></li><li><a href="#3">See also</a></li><li><a href="#4">Input arguments</a></li><li><a href="#5">Output arguments</a></li><li><a href="#6">Example</a></li></ul></div><h2 id="1">Syntax</h2><p>mesh_ovoid;</p><p>mesh_ovoid(nb_samples);</p><p>mesh_ovoid(nb_samples, option_display);</p><p>[V,T] = mesh_ovoid(nb_samples, option_display);</p><h2 id="2">Description</h2><p>mesh_ovoid compute and display a meshed ovoid made of 64 samples in longitude angle and 64 samples in latitude angle. The radius of the bottom half sphere equals 1.</p><p>mesh_ovoid(nb_samples) uses nb_samples for a half pi angle.</p><p>mesh_ovoid(nb_samples, option_display) displays the result when option_display is set to logical *true/*1 and doesn't when it is set to logical false/0.</p><p>[V,T] = mesh_ovoid(nb_samples, option_display) stores the resulting vertices coordinates in the array V, and the corresponding triplet indices list in the array T.</p><h2 id="3">See also</h2><p>| <a href="https://fr.mathworks.com/matlabcentral/fileexchange/85173-mesh-generation-toolbox">mesh generation toolbox</a> | <a href="https://fr.mathworks.com/matlabcentral/fileexchange/77004-mesh-processing-toolbox?s_tid=srchtitle">mesh processing toolbox</a> | <a href="https://fr.mathworks.com/help/matlab/ref/sphere.html">sphere</a> | <a href="https://fr.mathworks.com/help/matlab/ref/ellipsoid.html">ellipsoid</a> |</p><h2 id="4">Input arguments</h2><p>- nb_samples : positive integer double, nb_samples &gt; 2, the number of samples for 0.5*pi angle.</p><p>- option_display : either logical *true/false or numeric 1/0.</p><h2 id="5">Output arguments</h2><pre> [ | | |]
- V = [Vx Vy Vz], real matrix double, the vertex coordinates. Size(V) = [nb_vertices,3].
[ | | |]</pre><pre> [ | | |]
- T = [T1 T2 T3], positive integer matrix double, the triangulation. Size(T) = [nb_triangles,3].
[ | | |]</pre><h2 id="6">Example</h2><p>With default parameter values</p><pre class="codeinput">meshed_ovoid;
[ | | |]</pre><h2 id="6">Example</h2><p>With default parameter values</p><pre class="codeinput">mesh_ovoid;
</pre><img vspace="5" hspace="5" src="doc_01.png" alt=""> <p class="footer"><br><a href="https://www.mathworks.com/products/matlab/">Published with MATLAB&reg; R2019b</a><br></p></div><!--
##### SOURCE BEGIN #####
%% meshed_ovoid
%% mesh_ovoid
%
% Function to compute, display, and save a meshed ovoid.
%
% Author & support : nicolas.douillet (at) free.fr, 2020.
% Author & support : nicolas.douillet (at) free.fr, 2020-2023.
%
%% Syntax
%
% meshed_ovoid;
% mesh_ovoid;
%
% meshed_ovoid(nb_samples);
% mesh_ovoid(nb_samples);
%
% meshed_ovoid(nb_samples, option_display);
% mesh_ovoid(nb_samples, option_display);
%
% [V,T] = meshed_ovoid(nb_samples, option_display);
% [V,T] = mesh_ovoid(nb_samples, option_display);
%
%% Description
%
% meshed_ovoid compute and display a meshed ovoid made of 64 samples
% mesh_ovoid compute and display a meshed ovoid made of 64 samples
% in longitude angle and 64 samples in latitude angle. The radius of
% the bottom half sphere equals 1.
%
% meshed_ovoid(nb_samples) uses nb_samples for a half pi angle.
% mesh_ovoid(nb_samples) uses nb_samples for a half pi angle.
%
% meshed_ovoid(nb_samples, option_display) displays the result
% mesh_ovoid(nb_samples, option_display) displays the result
% when option_display is set to logical *true/*1 and doesn't when it is
% set to logical false/0.
%
% [V,T] = meshed_ovoid(nb_samples, option_display) stores the resulting
% [V,T] = mesh_ovoid(nb_samples, option_display) stores the resulting
% vertices coordinates in the array V, and the corresponding triplet
% indices list in the array T.
%
%% See also
%
% <https://fr.mathworks.com/help/matlab/ref/sphere.html sphere> |
% <https://fr.mathworks.com/help/matlab/ref/ellipsoid.html ellipsoid> |
% | <https://fr.mathworks.com/matlabcentral/fileexchange/85173-mesh-generation-toolbox mesh generation toolbox> |
% <https://fr.mathworks.com/matlabcentral/fileexchange/77004-mesh-processing-toolbox?s_tid=srchtitle
% mesh processing toolbox> |
% <https://fr.mathworks.com/help/matlab/ref/sphere.html sphere> |
% <https://fr.mathworks.com/help/matlab/ref/ellipsoid.html ellipsoid> |
%
%% Input arguments
%
Expand All @@ -129,6 +132,6 @@
%% Example
% With default parameter values
meshed_ovoid;
mesh_ovoid;
##### SOURCE END #####
--></body></html>
50 changes: 25 additions & 25 deletions meshed_ovoid.m → mesh_ovoid.m
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
function [V, T] = meshed_ovoid(nb_samples, option_display)
%% meshed_ovoid : function to compute, display, and save a meshed ovoid.
function [V, T] = mesh_ovoid(nb_samples, option_display)
% mesh_ovoid : function to compute, display, and save a meshed ovoid.
%
% Author & support : nicolas.douillet (at) free.fr, 2020.
% Author & support : nicolas.douillet (at) free.fr, 2020-2023.
%
%
% Syntax
%
% meshed_ovoid;
% meshed_ovoid(nb_samples);
% meshed_ovoid(nb_samples, option_display);
% [V,T] = meshed_ovoid(nb_samples, option_display);
% mesh_ovoid;
% mesh_ovoid(nb_samples);
% mesh_ovoid(nb_samples, option_display);
% [V,T] = mesh_ovoid(nb_samples, option_display);
%
% Description
%
% meshed_ovoid compute and display a meshed ovoid made of 64 samples
% mesh_ovoid compute and display a mesh ovoid made of 64 samples
% in longitude angle and 64 samples in latitude angle. The radius of
% the bottom half sphere equals 1.
%
% meshed_ovoid(nb_samples) uses nb_samples for a half pi angle.
% mesh_ovoid(nb_samples) uses nb_samples for a half pi angle.
%
% meshed_ovoid(nb_samples, option_display) displays the result
% mesh_ovoid(nb_samples, option_display) displays the result
% when option_display is set to logical *true/*1 and doesn't when it is
% set to logical false/0.
%
% [V,T] = meshed_ovoid(nb_samples, option_display) stores the resulting
% [V,T] = mesh_ovoid(nb_samples, option_display) stores the resulting
% vertices coordinates in the array V, and the corresponding triplet
% indices list in the array T.
%
Expand Down Expand Up @@ -51,10 +51,10 @@
%
% Example with default parameter values
%
% meshed_ovoid;
% mesh_ovoid;


%% Input parsing
% Input parsing
assert(nargin < 3,'Too many input arguments.');

if nargin < 2
Expand All @@ -63,7 +63,7 @@

if nargin < 1

nb_samples = 32;
nb_samples = 16;

else

Expand All @@ -78,7 +78,7 @@
end


%% Body
% Body
angle_step = pi/nb_samples;

% Z axis rotation matrix
Expand Down Expand Up @@ -110,7 +110,7 @@

S1 = numel(x);
S2 = 2*nb_samples+1;
T = build_triangulation(S1,S2);
T = build_triangulation(S1,S2,nb_samples);

% Remove duplicated vertices
[V,~,n] = unique(V,'rows','stable');
Expand All @@ -124,32 +124,32 @@
end


end % meshed_ovoid
end % mesh_ovoid


%% build_triangulation subfunction
function [T] = build_triangulation(S1, S2)
% build_triangulation subfunction
function [T] = build_triangulation(S1, S2, nb_samples)


r1 = cat(2,1,repelem(2:S1-1,2),S1);
r1 = reshape(r1,[2,S1-1])';
R1 = cat(2,r1,(1:S1-1)'+S1); % 1st triangle row indices
% size(R1,1) = S1-1
R1 = cat(1,R1,[2*nb_samples 2*nb_samples+1 1]); % add last triangle to connect
R1(1+floor(0.5*size(R1,1)):end,:) = fliplr(R1(1+floor(0.5*size(R1,1)):end,:));

r2 = cat(2,1+S1,repelem(2+S1:2*S1-1,2),2*S1);
r2 = reshape(r2,[2,S1-1])';
R2 = cat(2,(2:S1)',fliplr(r2)); % 2nd triangle row indices
% R2(1+floor(0.5*size(R2,1)):end,:) = fliplr(R2(1+floor(0.5*size(R2,1)):end,:));

T = repmat(cat(1,R1,R2),[S2-1,1]);
% size(T) = 2*(S1-1)*(S2-1)

T = T + S1*repelem((0:S2-2)',2*(S1-1),3);
T = repmat(cat(1,R1,R2),[S2-2,1]);
T = T + floor(0.5*S1)*repelem((0:S2-3)',2*(S1-1)+1,3);


end % build_triangulation


%% disp_ovoid subfunction
% disp_ovoid subfunction
function [] = disp_ovoid(V, T)


Expand Down
Binary file renamed meshed_ovoid_ls.mlx → mesh_ovoid_ls.mlx
Binary file not shown.

0 comments on commit 8e163c6

Please sign in to comment.