How to find out the coordinates of the rectangles through which a straight line passes?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clc;
clear all;
close all;
d1=5; %d1=Number of horizontal pixels+1
d2=5; %d2=Number of vertical pixels+1
dos=20;
X=zeros(d2,d1);
y=linspace(4,16,d1);
z=linspace(0,4,d2);
[Y,Z]=meshgrid(y,z);
A=mesh(X,Y,Z);
hold on
X1=zeros(d2,d1)+dos; %
y1=linspace(7,13,d1);
z1=linspace(0,2,d2);
[Y1,Z1]=meshgrid(y1,z1);
A1=mesh(X1,Y1,Z1);
%% Plotting of Straight Line Radiation from A towards A1
for k=(z(1)+0.5*(z(d2)-z(1))/(d2-1)):(z(d2)-z(1))/(d2-1):z(d2)
for j=(y(1)+0.5*(y(d1)-y(1))/(d1-1)):(y(d1)-y(1))/(d1-1):y(d1)
line([X(1),35],[j,j],[k,k],'Color','red');
end
end
I have two meshes 'A' and 'A1'.I have plotted straight lines from the centre of each rectangular cell of 'A'towards 'A1'.
I want to find out the coordinates of the rectangular cells of A1 through which any straight line from A passes. I can do this visually also but if the value of 'd1' and 'd2' will increase,then the process will become tiresome.
0 comentarios
Respuestas (2)
Image Analyst
el 13 de Feb. de 2022
From your plot, it looks like the red lines emanating from your left rectangle (in the Y-Z plane) intersect the inner, smaller rectangle perpendicularly. In that case, can't you just see if the (y, z) coordinate of the red line falls within the (y,z) range spanned by your inner rectangle. If it does, the (y,z) coordinates are the same, unless you're defining a new coordinate system for your inner rectangle.
0 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!