how to check if a 3D point is inside a 3D cone
31 次查看(过去 30 天)
显示 更早的评论
R = 3; %// radius
H = 1; %// height
N = 100; %// number of points to define the circumference
[x, y, z] = cylinder([0 R], N);
mesh(x+3, y+3, H*z)%cone at(3,3,0)
zlim([0 5])
xlim([0 5])
ylim([0 5])
[EDITED, Jan, Code formatted]
0 个评论
回答(1 个)
Jim Riggs
2018-6-29
1) Define a unit vector, U, which points along the axis of the cone.
2) Define vector VR which points from the cone vertex, V, to the point in question, R. Normalize vector VR to a unit vector Uvr.
3) Take the dot product Uvr dot U. This is the cosine of the angle between VR and U.
4) Take the arc cosine of the value from (3). If this angle is larger than the cone angle, the point is outside the cone.
3 个评论
Tamoor Shafique
2022-4-7
How can we define vector U in matlab with a given vertex to create the cone?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!