Home > matGeom > polygons2d > intersectRayPolygon.m

intersectRayPolygon

PURPOSE ^

Intersection points between a ray and a polygon.

SYNOPSIS ^

function [intersects, edgeIndices] = intersectRayPolygon(ray, poly, varargin)

DESCRIPTION ^

 Intersection points between a ray and a polygon.

   PTS = intersectRayPolygon(RAY, POLY)
   Returns the intersection points of the ray RAY with polygon POLY. 
   RAY is a 1x4 array containing parametric representation of the ray
   (in the form [x0 y0 dx dy], see createRay for details). 
   POLY is a N-by-2 array containing coordinates of polygon vertices.
   
   [PTS, INDS] = intersectRayPolygon(...)
   Also returns index of polygon intersected edge(s). See
   intersectLinePolygon for details.

   See also
     rays2d, polygons2d, intersectLinePolygon

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [intersects, edgeIndices] = intersectRayPolygon(ray, poly, varargin)
0002 % Intersection points between a ray and a polygon.
0003 %
0004 %   PTS = intersectRayPolygon(RAY, POLY)
0005 %   Returns the intersection points of the ray RAY with polygon POLY.
0006 %   RAY is a 1x4 array containing parametric representation of the ray
0007 %   (in the form [x0 y0 dx dy], see createRay for details).
0008 %   POLY is a N-by-2 array containing coordinates of polygon vertices.
0009 %
0010 %   [PTS, INDS] = intersectRayPolygon(...)
0011 %   Also returns index of polygon intersected edge(s). See
0012 %   intersectLinePolygon for details.
0013 %
0014 %   See also
0015 %     rays2d, polygons2d, intersectLinePolygon
0016 %
0017 
0018 % ------
0019 % Author: David Legland
0020 % e-mail: david.legland@inrae.fr
0021 % created the 26/01/2010
0022 
0023 
0024 %   HISTORY
0025 %   2010/01/26 creation from intersectLinePolygon
0026 %   2013-02-11 also returns edgeIndices
0027 
0028 % compute intersections with supporting line
0029 [intersects, edgeIndices, pos] = intersectLinePolygon(ray, poly, varargin{:});
0030 
0031 % keep only intersects with non-negative position on line
0032 indPos = pos >= 0;
0033 intersects  = intersects(indPos, :);
0034 edgeIndices = edgeIndices(indPos);

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