Skip to content
Snippets Groups Projects
Commit cec7b618 authored by Ivar Stefansson's avatar Ivar Stefansson
Browse files

Replace intersections_of_cells.m

parent 9cdf724c
No related branches found
No related tags found
No related merge requests found
function [ int_points ] = intersections_of_cells( line_points, ...
vertical_line, c_p_on, c_p_nw_on )
%UNTITLED5 The matrix int_points contains the intersections with the line
%specified by line_points for each of the cells defined by the points in
%c_p_on. The format for the intersection points is x1,y1,x2,y2
int_points = zeros(length(c_p_on),4);
%length_on = zeros(length(c_p_on));
for c = 1:length(c_p_on)
ind = 1; % places the points in the right position in the matrix line (c,:)
l = length(c_p_on{c});
for v = 1:l
if v < l
i = v+1; % could perhaps be handled with modulus, but =0 has to
%be avoided
else
i = 1;
end
% If the two points of a face are on opposite sides of the line,
% the face intersects the line:
if c_p_nw_on{c}(v) ~= c_p_nw_on{c}(i)
face_points = [c_p_on{c}(v,:); c_p_on{c}(i,:)];
vertical_face = abs(c_p_on{c}(v,1)- c_p_on{c}(i,1)) < 5*eps;
%find intersection points:
int_points(c,ind:ind+1) = intersection(line_points, ...
vertical_line, face_points, ...
vertical_face);
ind = ind + 2;
end
end
end
end
function [ intersectionPoints ] = intersections_of_cells( linePoints, ...
verticalLine, cellPointsOn, cellPointsNortWestOn )
%UNTITLED5 The matrix intersectionPoints contains the intersections with the line
%specified by linePoints for each of the cells defined by the points in
%cellPointsOn. The format for the intersection points is x1,y1,x2,y2
intersectionPoints = zeros(length(cellPointsOn),4);
for c = 1:length(cellPointsOn)
ind = 1; % places the points in the right position in the matrix line (c,:)
l = length(cellPointsOn{c});
for v = 1:l
if v < l
i = v+1; % could perhaps be handled with modulus, but =0 has to
%be avoided
else
i = 1;
end
% If the two points of a face are on opposite sides of the line,
% the face intersects the line:
if cellPointsNortWestOn{c}(v) ~= cellPointsNortWestOn{c}(i)
facePoints = [cellPointsOn{c}(v,:); cellPointsOn{c}(i,:)];
verticalFace = abs(cellPointsOn{c}(v,1)- cellPointsOn{c}(i,1)) < 5*eps;
%find intersection points:
intersectionPoints(c,ind:ind+1) = intersection(linePoints, ...
verticalLine, facePoints, ...
verticalFace);
ind = ind + 2;
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment