I want to find out points whose coordinates are within the volume formed by a cone shape.

Hello,
I have plotted few points in a 3D volume as shown in the figure below:
I want to plot a 3D righ Cone from a few specefic points as shown:
These cones are 3D volumes and I want to find out points whose coordinates are within each cone. for example which point is within yello cone and which one in red and which one in purple cone.
Can some one help?

 Accepted Answer

Assuming
  • the cone center is C: (3 x 1)
  • coneangle is the cone angle (0 to pi, pi corresponds to the extreme case where the cone takes the whole space)
  • the cone axis is N: (3 x 1), oriented toward the direction you consider to be in
  • Point P: (3 x 1) the point coordinates to be check
Check inside the half of the cone is
dot(P-C, N) >= cos(coneangle/2) * norm(N) * norm(P-C)
You can compute once
cos(coneangle/2) * norm(N)
if you have many points P to check.

3 Comments

Sorry one more problem:
Why is following not giving me a 3D Cone but a 2D Cone? How can I convert it into a 3D Cone?
function [X2,Y2,Z2] = cone_plot3(r,h,phi,theta,offset)
m = h/r;
[R,A] = meshgrid(linspace(0,r,50),linspace(0,2*pi,50));
X = R.*cos(A);
Y = R.*sin(A);
Z = m*R;
% Cone around the z-axis, point at the origin
X1 = X*cos(phi) - Z*sin(phi);
Y1 = Y;
Z1 = X*sin(phi) + Z*cos(phi);
% Previous cone, rotated by angle phi about the y-axis
X2 = X1*cos(theta) + offset(1);
Y2 = X1*sin(theta) + offset(2);
Z2 = Z1 + offset(3);
% Second cone rotated by angle theta about the z-axis
end
The Code is
clc
clear all
r=10;
h=30;
phi=pi/3;
theta=pi/4;
offset(1)=10;
offset(2)=10;
offset(3)=10;
[X3 Y3 Z3]=cone_plot3(r,h,phi,theta,offset)
surf(X3, Y3, Z3)
Any help would be welcomed
The above code plots one part of the surface of the cone truncated at base hight = h, base radius r.
Why? Because the author wants it that way.
I got it. sorry for being so dumb.
Thank you very much and much appreciated.
I have resolved this problem

Sign in to comment.

More Answers (1)

Draw a vector from the cone vertex to the point and compute the angle of this vector to the cone's axis. If the angle is less than the angular width of the cone, then the point is inside the cone. This assumes that the cone is not of finite length.

4 Comments

but in that case the points on the other half of the cubic/circular region will also be considered within the cone when they are not how do i make sure it only checks upto the base of the cone only?
I don't know how you are parametrizing the cone. Ideally you would have the vertex, the cone angle, and the direction vector of the cone's axis. Without loss of generality, assume the vertex is at the origin (you can always shift your coordinate system to achieve this). Then the position vector of your query point needs to form an acute angle with respect to the direction vector of the cone's axis.
Sorry one more problem:
Why is following not giving me a 3D Cone but a 2D Cone? How can I convert it into a 3D Cone?
function [X2,Y2,Z2] = cone_plot3(r,h,phi,theta,offset)
m = h/r;
[R,A] = meshgrid(linspace(0,r,50),linspace(0,2*pi,50));
X = R.*cos(A);
Y = R.*sin(A);
Z = m*R;
% Cone around the z-axis, point at the origin
X1 = X*cos(phi) - Z*sin(phi);
Y1 = Y;
Z1 = X*sin(phi) + Z*cos(phi);
% Previous cone, rotated by angle phi about the y-axis
X2 = X1*cos(theta) + offset(1);
Y2 = X1*sin(theta) + offset(2);
Z2 = Z1 + offset(3);
% Second cone rotated by angle theta about the z-axis
end
The Code is
clc
clear all
r=10;
h=30;
phi=pi/3;
theta=pi/4;
offset(1)=10;
offset(2)=10;
offset(3)=10;
[X3 Y3 Z3]=cone_plot3(r,h,phi,theta,offset)
surf(X3, Y3, Z3)
Any help would be welcomed
What are the geometric meanings of r,h,phi,theta,offset?

Sign in to comment.

Categories

Products

Release

R2021a

Asked:

on 27 Apr 2022

Edited:

on 28 Apr 2022

Community Treasure Hunt

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

Start Hunting!