intersect edit page

length of a boundary segment

Syntax

[x,y] = intersect(gB,xy1,xy2)
[x,y,segLength] = intersect(gB,xy1,xy2)

Input

gb grainBoundary
xy1, xy2 coordinates of the endpoints of the line

Output

x,y list of intersection points

Example

mtexdata small
grains = calcGrains(ebsd('indexed'))
grains = smooth(grains,4)
plot(grains.boundary,'micronbar','off')
% define some line
xy1 = [33500,4500];  % staring point
xy2 = [36000,7500]; % end point
line([xy1(1);xy2(1)],[xy1(2);xy2(2)],'linewidth',1.5,'color','g')
[x,y] = grains.boundary.intersect(xy1,xy2);
hold on
scatter(x,y,'red')
% find the number of intersection points
sum(~isnan(x))
% mark the intersected boundary segments
plot(grains.boundary(~isnan(x)),'lineColor','b','linewidth',2)
hold off