フィルターのクリア

Checking if 3D straight line intersects a rectangular grid cell.

3 ビュー (過去 30 日間)
Fyodor Tatarinov
Fyodor Tatarinov 2020 年 9 月 30 日
回答済み: Shadaab Siddiqie 2020 年 10 月 7 日
I have a 3D logical matrix (each element means: "filled" or "empty") representing a 3D volume (spatial step in each dimension is the same). I need to check, which grid cells is crossing a beam (sraight line) going from a particular point in particular direction (vertical angle and azimuth). Are there any standard scripts for it?
Thanks

採用された回答

Shadaab Siddiqie
Shadaab Siddiqie 2020 年 10 月 7 日
From my understanding you want to find all the cells in a 3D matrix which is intersected by an 3D line (given vertical angle and azimuth). You could convert spatial coordinates to cartesian coordinate to map it with the 3D matrix and then make small increments to find all the cells in the matrix that are in your path (with some conditions). Here is a simple script that might be helpfull.
A = zeros(3, 3, 3);
teta = pi/10; % vertical angle
phi = pi/6; % azimuth
smallstep = 1; % you can make it smaller for more precision eg:0.5
for r = 0:1:3
x = r*sin(teta)*cos(phi);
y = r*sin(teta)*sin(phi);
z = r*cos(teta);
if A(round(x),round(y),round(z)) == 0: % any condition that you need
disp([round(x) round(y) round(z)]);
end
end
For more information please refer pol2cart and sph2cart if you need other conversions. Also, you can refer this wiki page for more information.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMotion Modeling and Coordinate Systems についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by