Home > matGeom > meshes3d > intersectEdgeMesh3d.m

intersectEdgeMesh3d

PURPOSE ^

Intersection points of a 3D edge with a mesh.

SYNOPSIS ^

function [points, pos, faceInds] = intersectEdgeMesh3d(edge, varargin)

DESCRIPTION ^

 Intersection points of a 3D edge with a mesh.

   INTERS = intersectEdgeMesh3d(EDGE, VERTICES, FACES)
   Compute the intersection points between a 3D edge and a 3D mesh defined
   by vertices and faces.

   [INTERS, POS, INDS] = intersectEdgeMesh3d(EDGE, VERTICES, FACES)
   Also returns the position of each intersection point on the input edge,
   and the index of the intersected faces.
   For edges, the values of POS are expected to be comprised between 0 and
   1.
   
   Example
     [V, F] = createCube;
     edge = [-1 0.5 0.5  +3 0.5 0.5];
     pts = intersectEdgeMesh3d(edge, V, F)
     pts =
         1.0000    0.5000    0.5000
              0    0.5000    0.5000

   See also
     meshes3d, interesectLineMesh3d, triangulateFaces

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [points, pos, faceInds] = intersectEdgeMesh3d(edge, varargin)
0002 % Intersection points of a 3D edge with a mesh.
0003 %
0004 %   INTERS = intersectEdgeMesh3d(EDGE, VERTICES, FACES)
0005 %   Compute the intersection points between a 3D edge and a 3D mesh defined
0006 %   by vertices and faces.
0007 %
0008 %   [INTERS, POS, INDS] = intersectEdgeMesh3d(EDGE, VERTICES, FACES)
0009 %   Also returns the position of each intersection point on the input edge,
0010 %   and the index of the intersected faces.
0011 %   For edges, the values of POS are expected to be comprised between 0 and
0012 %   1.
0013 %
0014 %   Example
0015 %     [V, F] = createCube;
0016 %     edge = [-1 0.5 0.5  +3 0.5 0.5];
0017 %     pts = intersectEdgeMesh3d(edge, V, F)
0018 %     pts =
0019 %         1.0000    0.5000    0.5000
0020 %              0    0.5000    0.5000
0021 %
0022 %   See also
0023 %     meshes3d, interesectLineMesh3d, triangulateFaces
0024 %
0025 
0026 % ------
0027 % Author: David Legland
0028 % e-mail: david.legland@inrae.fr
0029 % Created: 2021-02-24,    using Matlab 9.9.0.1570001 (R2020b) Update 4
0030 % Copyright 2021 INRA - Cepia Software Platform.
0031 
0032 % perform computation on supporting line
0033 line = edgeToLine3d(edge);
0034 [points, pos, faceInds] = intersectLineMesh3d(line, varargin{:});
0035 
0036 % identifies intersection points within parameterization bounds
0037 inds = pos >= 0 & pos <= 1;
0038 
0039 % select relevant results
0040 points = points(inds, :);

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019