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