Find only interior points from set of points
Mostra commenti meno recenti
I have a collection of interior and exterior points and need to remove all exterior points from the set. The points can be in any order and any shape. The exterior shape does not have to match the interior shape. However, the inner shape NEVER intersects the outer shape. Both shapes share a common "center" point and I have that data. For example, I could have the points like...
t1 = linspace(0,2*pi, 100);
t2 = wrapTo2Pi(t1 + 0.05);
r1 = 5;
r2 = 10;
r3 = 7;
r4 = 12;
x1 = r1*cos(t1);
y1 = r2*sin(t1);
x2 = r3*cos(t2);
y2 = r4*sin(t2);
xGiven = [x1, x2];
yGiven = [y1, y2];
figure()
scatter(xGiven , yGiven);
Assume, that the only information provided is xGiven, and yGiven. No information on how they were constructed is provided.
Here, I only want the points of the interior ring. The common point shared is [0,0] since both shapes are symmetric about that point.
The only toolbox I have access to is the signal processing toolbox.
Any suggestions would be greatly appreciated.
Risposta accettata
Più risposte (1)
The following is an example:
% Sample data
rng('default');
x = rand(100, 1);
y = rand(100, 1);
% Identiry exterior points
k = boundary(x, y);
% Create index
idxExterior = false(size(x));
idxExterior(k) = true;
idxInterior = ~idxExterior;
% Show the result
figure
tiledlayout('flow')
ax1 = nexttile;
scatter(x,y, 'b.')
daspect([1 1 1])
title('All points')
ax2 = nexttile;
scatter(x(idxExterior), y(idxExterior), 'r.')
daspect([1 1 1])
title('Exterior points')
ax3 = nexttile;
scatter(x(idxInterior), y(idxInterior), 'm.')
daspect([1 1 1])
title('Interior points')
linkaxes([ax1, ax2, ax3], 'xy')
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


