Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Detect if a point is inside of a cone or not, in 3D space

Subject: Detect if a point is inside of a cone or not, in 3D space

From: Paulo

Date: 28 Apr, 2009 01:02:02

Message: 1 of 8

Hi everyone,

How is possible to detect if a 3D point is inside of a cone or not?

Thank you for your attention.

Subject: Detect if a point is inside of a cone or not, in 3D space

From: Gustavo Morales

Date: 28 Apr, 2009 02:02:01

Message: 2 of 8

Paulo:

Hi..!

Because of a closed surface divides the 3D space in 3 regions:
  1) On the surface
  2) Outside the surface
  3) Inside the surface (region enclosed by the surface)

you could write the equation in implicit form: f(x,y,z) = 0. If you evaluate f(x,y,z) with Points p(x',y',z') that are on the surface, it will produce a zero value. If the value you obtained this way is greater than zero, p should be outside. If it is lower than zero, p should be inside.
For example, let's suppose the cone equation is f(x,y,z) = 0, and point p has coordinates xo, yo, zo. Try this:
cone = @(x,y,z) f(x,y,z); % anonymous function handle for f(x,y,z)
p = [xo, yo, zo]; % test point
cone(p(1),p(2),p(3)) % evaluating f(x,y,z)

ans =

   "fvalue"

If it is negative, p is inside the cone...

Subject: Detect if a point is inside of a cone or not, in 3D space

From: Gustavo Morales

Date: 28 Apr, 2009 02:09:02

Message: 3 of 8

Paulo:

I don't know how do you want to implement your checking, but, if you just want to see the surface and the point, do this:
-Search and download in File Exchange (MFX) EZIMPLOT3 (done by me)
-Copy EZIMPLOT3 in your Matlab path
-Write at the command window:

plot3(p(1),p(2),p(3))
hold on
ezimplot3(cone)

and you'll can check where "p" is...

Regards from Venezuela!

Subject: Detect if a point is inside of a cone or not, in 3D space

From: Gustavo Morales

Date: 28 Apr, 2009 03:37:01

Message: 4 of 8

Paulo:

Upps! I forgot something.
If you want to see just a point with plot3, you must to change the default marker "." to a visible marker like "o"

> plot3(p(1),p(2),p(3),'o') % :-)
> hold on
> ezimplot3(cone) % my ezimplot3 plotter of implicit surfaces

Subject: Detect if a point is inside of a cone or not, in 3D space

From: rych

Date: 30 Apr, 2009 16:12:45

Message: 5 of 8

On Apr 28, 3:02 am, "Gustavo Morales" <gustavo.morales.2...@gmail.com>
wrote:
> Because of a closed surface divides the 3D space in 3 regions:
>   1) On the surface
>   2) Outside the surface
>   3) Inside the surface (region enclosed by the surface)
>
> you could write the equation in implicit form: f(x,y,z) = 0. If you eva=
luate f(x,y,z) with Points p(x',y',z') that are on the surface, it will pro=
duce a zero value. If the value you obtained this way is greater than zero,=
 p should be outside. If it is lower than zero, p should be inside.
>
Gustavo,
Where/how is this proved? That for any closed surface f(x,y,z)=0 all
points "inside" have the same sign(f(x,y,z))?
Thanks
Igor

Subject: Detect if a point is inside of a cone or not, in 3D space

From: Matt

Date: 30 Apr, 2009 19:22:01

Message: 6 of 8

"Paulo " <paulofreitas7@portugalmail.pt> wrote in message <gt5kia$2c1$1@fred.mathworks.com>...
> Hi everyone,
>
> How is possible to detect if a 3D point is inside of a cone or not?
>
> Thank you for your attention.

Write down the equation (or rather the inequality) describing the inside of the cone and then see if the given 3D point satisfies it.

If you're dealing with a traditional cone, with circular cross-sections, in which case the inside of the cone is described by something like

x^2+y2-z^2<=0

Subject: Detect if a point is inside of a cone or not, in 3D space

From: Gustavo Morales

Date: 4 May, 2009 21:06:02

Message: 7 of 8

rych <rychphd@gmail.com> wrote in message <c3acb871-6689-46f7-95ca-ea2efd9f3a83@i28g2000prd.googlegroups.com>...
> On Apr 28, 3:02?am, "Gustavo Morales" <gustavo.morales.2...@gmail.com>
> wrote:
> > Because of a closed surface divides the 3D space in 3 regions:
> > ? 1) On the surface
> > ? 2) Outside the surface
> > ? 3) Inside the surface (region enclosed by the surface)
> >
> > you could write the equation in implicit form: f(x,y,z) = 0. If you eva=
> luate f(x,y,z) with Points p(x',y',z') that are on the surface, it will pro=
> duce a zero value. If the value you obtained this way is greater than zero,=
> p should be outside. If it is lower than zero, p should be inside.
> >
> Gustavo,
> Where/how is this proved? That for any closed surface f(x,y,z)=0 all
> points "inside" have the same sign(f(x,y,z))?
> Thanks
> Igor

I'm just an Electrical Engineer, but I'll try to give you an answer (A mathematician could correct me, excuses for my english):

w = f(x,y,z) is a 4D function whose <level-surfaces> are of the form:
f(x,y,z) = wo (constant). By other way, the gradient of w: grad(w) points toward the 3D regions where w has max increment, so:
 if f(x,y,z) = wo over the surface, f(x,y,z) must be greater than wo if you moves from the surface along the direction give it by grad(w). On the contrary, if you moves from the surface along the opposite direction, f(x,y,z) must take values lower than wo. So f(x,y,z) will go taking lower and lower values

Now, you can imagine that wo = 0 and........ the tail is over....

P.D.: I don't know how to ensure that grad(w) points out of a closed level-surface (I'm sure not always do, i.e. the gradient of scalar potential for a positive charge) and if it is relevant this approach for my explanation...

Maybe an explanation based on the concept of solid angle could help us...

Subject: Detect if a point is inside of a cone or not, in 3D space

From: sh

Date: 26 Jun, 2013 19:18:06

Message: 8 of 8

how to detect it in a 2D dimension? thanks

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us