/ proof-of-concept / bead-percussion
Sign in
proof-of-concept / bead-percussion
bead-percussion / matlab / helpers / bp_near.m
13 lines · 361 BBlameHistoryRaw
1function idx = bp_near(pos, p, r)
2% BP_NEAR Beads near a point.
3% idx = bp_near(pos, p, r) returns the beads within distance r of point p
4% (1-by-3). With r = 0, or if no bead is that close, returns the nearest bead.
5if numel(p) == 2
6 p = [p(:)', 0];
7end
8d = vecnorm(pos - p(:)', 2, 2);
9idx = find(d <= r);
10if isempty(idx)
11 [~, idx] = min(d);
12end
13end
↑↓ move↵openescclose