diff --git a/demos/meshes3d/demoIntersectLineMesh3d.m b/demos/meshes3d/demoIntersectLineMesh3d.m new file mode 100644 index 00000000..854fcb79 --- /dev/null +++ b/demos/meshes3d/demoIntersectLineMesh3d.m @@ -0,0 +1,56 @@ +% Demonstration of the intersectLineMesh3d function. +% +% output = demoIntersectLineMesh3d(input) +% +% Example +% demoIntersectLineMesh3d +% +% See also +% + +% ------ +% Author: David Legland +% e-mail: david.legland@inrae.fr +% INRAE - BIA Research Unit - BIBS Platform (Nantes) +% Created: 2021-08-02, using Matlab 9.10.0.1684407 (R2021a) Update 3 +% Copyright 2021 INRAE. + + +%% Input mesh + +% create the mesh +[v, f] = createOctahedron; +v = v * 10; + +% draw the mesh +figure; hold on; axis equal; view(3); +axis([-10 10 -10 10 -10 10]); +drawMesh(v, f, 'g'); + + +%% Input lines +% create a collection of parallel lines + +% line direction is mostly horizontal +vl = [3 2 1]; + +% choose several origins for lines +ly = -8:4:8; +lz = -8:4:8; +[y0, z0] = meshgrid(ly, lz); +x0 = zeros(size(y0)); + +% create the lines +lines = [x0(:) y0(:) z0(:) repmat(vl, numel(y0), 1)]; + +% draw the lines +drawLine3d(lines, 'b'); + + +%% Compute intersections + +% compute intersections +inters = intersectLineMesh3d(lines, v, f); + +% draw intersection points +drawPoint3d(inters, 'ko'); diff --git a/demos/meshes3d/demoIntersectPlaneMesh.m b/demos/meshes3d/demoIntersectPlaneMesh.m new file mode 100644 index 00000000..fe093969 --- /dev/null +++ b/demos/meshes3d/demoIntersectPlaneMesh.m @@ -0,0 +1,63 @@ +% Demonstration of the intersectPlaneMesh function. +% +% output = demoIntersectPlaneMesh(input) +% +% Example +% demoIntersectPlaneMesh +% +% See also +% + +% ------ +% Author: David Legland +% e-mail: david.legland@inrae.fr +% INRAE - BIA Research Unit - BIBS Platform (Nantes) +% Created: 2021-08-02, using Matlab 9.10.0.1684407 (R2021a) Update 3 +% Copyright 2021 INRAE. + + +%% Input mesh + +% create the mesh +[v, f] = createOctahedron; +v = v * 10; + +% draw the mesh +figure; hold on; axis equal; view(3); +axis([-10 10 -10 10 -10 10]); +drawMesh(v, f, 'g'); + + +%% Input planes +% create a collection of parallel planes + +% planedirection is mostly horizontal +normal = [2 3 8]; + +% choose several origins for planes +origins = [zeros(5, 2) (-8:4:8)']; +nPlanes = size(origins, 1); + +% create the planes +planes = zeros(nPlanes, 9); +for i = 1:nPlanes + planes(i,:) = createPlane(origins(i,:), normal); +end + +% draw the lines +drawPlane3d(planes, 'FaceColor', 'blue', 'FaceAlpha', .4); + + +%% Compute intersections + +% allocate array +polySets = cell(1, nPlanes); + +% compute intersections +for i = 1:nPlanes + polys = intersectPlaneMesh(planes(i,:), v, f); + polySets{i} = polys; +end + +% draw intersection points +drawPolygon3d(polySets, 'Color', 'magenta', 'LineWidth', 2); diff --git a/demos/meshes3d/html/demoIntersectLineMesh3d.html b/demos/meshes3d/html/demoIntersectLineMesh3d.html new file mode 100644 index 00000000..2da07d36 --- /dev/null +++ b/demos/meshes3d/html/demoIntersectLineMesh3d.html @@ -0,0 +1,173 @@ + + + + + demoIntersectLineMesh3d

Contents

% Demonstration of the intersectLineMesh3d function.
+%
+%   output = demoIntersectLineMesh3d(input)
+%
+%   Example
+%   demoIntersectLineMesh3d
+%
+%   See also
+%
+
+% ------
+% Author: David Legland
+% e-mail: david.legland@inrae.fr
+% INRAE - BIA Research Unit - BIBS Platform (Nantes)
+% Created: 2021-08-02,    using Matlab 9.10.0.1684407 (R2021a) Update 3
+% Copyright 2021 INRAE.
+

Input mesh

% create the mesh
+[v, f] = createOctahedron;
+v = v * 10;
+
+% draw the mesh
+figure; hold on; axis equal; view(3);
+axis([-10 10 -10 10 -10 10]);
+drawMesh(v, f, 'g');
+

Input lines

create a collection of parallel lines

% line direction is mostly horizontal
+vl = [3 2 1];
+
+% choose several origins for lines
+ly = -8:4:8;
+lz = -8:4:8;
+[y0, z0] = meshgrid(ly, lz);
+x0 = zeros(size(y0));
+
+% create the lines
+lines = [x0(:) y0(:) z0(:) repmat(vl, numel(y0), 1)];
+
+% draw the lines
+drawLine3d(lines, 'b');
+

Compute intersections

% compute intersections
+inters = intersectLineMesh3d(lines, v, f);
+
+% draw intersection points
+drawPoint3d(inters, 'ko');
+
\ No newline at end of file diff --git a/demos/meshes3d/html/demoIntersectLineMesh3d.png b/demos/meshes3d/html/demoIntersectLineMesh3d.png new file mode 100644 index 00000000..8bf2c1b5 Binary files /dev/null and b/demos/meshes3d/html/demoIntersectLineMesh3d.png differ diff --git a/demos/meshes3d/html/demoIntersectLineMesh3d_01.png b/demos/meshes3d/html/demoIntersectLineMesh3d_01.png new file mode 100644 index 00000000..e8d3132e Binary files /dev/null and b/demos/meshes3d/html/demoIntersectLineMesh3d_01.png differ diff --git a/demos/meshes3d/html/demoIntersectLineMesh3d_02.png b/demos/meshes3d/html/demoIntersectLineMesh3d_02.png new file mode 100644 index 00000000..3c19e438 Binary files /dev/null and b/demos/meshes3d/html/demoIntersectLineMesh3d_02.png differ diff --git a/demos/meshes3d/html/demoIntersectLineMesh3d_03.png b/demos/meshes3d/html/demoIntersectLineMesh3d_03.png new file mode 100644 index 00000000..1f2d3450 Binary files /dev/null and b/demos/meshes3d/html/demoIntersectLineMesh3d_03.png differ diff --git a/demos/meshes3d/html/demoIntersectPlaneMesh.html b/demos/meshes3d/html/demoIntersectPlaneMesh.html new file mode 100644 index 00000000..a28fb3c3 --- /dev/null +++ b/demos/meshes3d/html/demoIntersectPlaneMesh.html @@ -0,0 +1,187 @@ + + + + + demoIntersectPlaneMesh

Contents

% Demonstration of the intersectPlaneMesh function.
+%
+%   output = demoIntersectPlaneMesh(input)
+%
+%   Example
+%   demoIntersectPlaneMesh
+%
+%   See also
+%
+
+% ------
+% Author: David Legland
+% e-mail: david.legland@inrae.fr
+% INRAE - BIA Research Unit - BIBS Platform (Nantes)
+% Created: 2021-08-02,    using Matlab 9.10.0.1684407 (R2021a) Update 3
+% Copyright 2021 INRAE.
+

Input mesh

% create the mesh
+[v, f] = createOctahedron;
+v = v * 10;
+
+% draw the mesh
+figure; hold on; axis equal; view(3);
+axis([-10 10 -10 10 -10 10]);
+drawMesh(v, f, 'g');
+

Input planes

create a collection of parallel planes

% planedirection is mostly horizontal
+normal = [2 3 8];
+
+% choose several origins for planes
+origins = [zeros(5, 2) (-8:4:8)'];
+nPlanes = size(origins, 1);
+
+% create the planes
+planes = zeros(nPlanes, 9);
+for i = 1:nPlanes
+    planes(i,:) = createPlane(origins(i,:), normal);
+end
+
+% draw the lines
+drawPlane3d(planes, 'FaceColor', 'blue', 'FaceAlpha', .4);
+

Compute intersections

% allocate array
+polySets = cell(1, nPlanes);
+
+% compute intersections
+for i = 1:nPlanes
+    polys = intersectPlaneMesh(planes(i,:), v, f);
+    polySets{i} = polys;
+end
+
+% draw intersection points
+drawPolygon3d(polySets, 'Color', 'magenta', 'LineWidth', 2);
+
\ No newline at end of file diff --git a/demos/meshes3d/html/demoIntersectPlaneMesh.png b/demos/meshes3d/html/demoIntersectPlaneMesh.png new file mode 100644 index 00000000..f6f91b4e Binary files /dev/null and b/demos/meshes3d/html/demoIntersectPlaneMesh.png differ diff --git a/demos/meshes3d/html/demoIntersectPlaneMesh_01.png b/demos/meshes3d/html/demoIntersectPlaneMesh_01.png new file mode 100644 index 00000000..8b1c239d Binary files /dev/null and b/demos/meshes3d/html/demoIntersectPlaneMesh_01.png differ diff --git a/demos/meshes3d/html/demoIntersectPlaneMesh_02.png b/demos/meshes3d/html/demoIntersectPlaneMesh_02.png new file mode 100644 index 00000000..ca46b222 Binary files /dev/null and b/demos/meshes3d/html/demoIntersectPlaneMesh_02.png differ diff --git a/demos/meshes3d/html/demoIntersectPlaneMesh_03.png b/demos/meshes3d/html/demoIntersectPlaneMesh_03.png new file mode 100644 index 00000000..e4fe2553 Binary files /dev/null and b/demos/meshes3d/html/demoIntersectPlaneMesh_03.png differ