Commit 282a6440 authored by Larkin Heintzman's avatar Larkin Heintzman

Upload New File

parent 852e9434
Pipeline #27 canceled with stages
function nearest_vertex = getNearestVertex(q_point, vertex_coords, search_radius)
empty_entry = zeros(size(vertex_coords(1,:)));
vertex_coords_trimmed = vertex_coords([1, 3:length(vertex_coords)],:); % ignore entry 2
% vertex_coords_trimmed = vertex_coords;
vertex_coords_trimmed = vertex_coords_trimmed(any(vertex_coords_trimmed ~= empty_entry,2),:); % get rid of zero zero entries
q_dist = sqrt((q_point(1) - vertex_coords_trimmed(:,1)).^2 + (q_point(2) - vertex_coords_trimmed(:,2)).^2);
if search_radius == -1 % only want the nearest point, not list
[~, nearest_index] = min(q_dist);
nearest_vertex = vertex_coords_trimmed(nearest_index,:);
else
% looking for a list of vertices that are within the search radius
nearest_vertex = vertex_coords_trimmed(q_dist <= search_radius,:);
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment