- Convert the (x,y) coordinates of the 5 holes to polar coordinates using [theta,rho]=cart2pol(x,y)
- The rho values are the radial distances from the hole coordinates to the center of the target. Compare those results against the eccentricities of the rings to determine which ring each hole belongs to.
How to find where a circle lie between which range?
3 views (last 30 days)
Ive a probelem where I need to caclculate the score of the bullet holes or makings. I was able to find the bullet holes or small circles, and was also able to detect the ranges or big circles. I just to make a loop that will detect where these small circles lie between which range.
Adam Danz on 28 Dec 2021
Create target and holes
radii = 1:10;
theta = linspace(0,2*pi);
for r = radii
plot(r*sin(theta), r*cos(theta), 'r-')
% add holes
rng('default') % for reproducibility
[xHole, yHole] = pol2cart(2*pi*rand(1,5), 10*rand(1,5));
plot(xHole, yHole, 'k*', 'MarkerSize', 10, 'LineWidth', 1)
% Label bands
text(radii, radii*0, compose('%g',radii),'HorizontalAlignment','right')
Given coordinates of holes (xHole, yHole) and the radii of target bands (radii), identify the band that contains each hole.
% Measure distance to center
[~, holeRad] = cart2pol(xHole, yHole);
radiiInf = [radii, inf]; % to account for holes outside of outer ring
% Identify band for each hole
[~, bandIdx] = max(holeRad(:) <= radiiInf,,2);
holeBand = radiiInf(bandIdx);
% Show results in table
T = table(xHole(:), yHole(:), holeRad(:), holeBand(:), ...
% Label the band for each hole
text(xHole+.5, yHole, compose('%g', holeBand), 'Color', 'b')