Click here to Skip to main content
13,141,157 members (62,899 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I have to write down a program that takes a point in 3d as input and tells if the point is inside a 3d cone ?
Posted 21-Sep-14 19:32pm
Comments
   
Please, where is your problem, in middle school mathematics? Just a hint: this is a simple 2D problem.
—SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Some more of a hint:

This is a simple 2D problem. I assume this is a cone based on a circle. Dissect the cone with the plane passing through its axis. Consider the problem in this plane. You will get two symmetric rectangles formed by this axis and intersection with the cone surface, with the common vertex. Drop perpendicular from the point in question to the axis:
  /|
 / |   *?
/__|___|
\  |
 \ |
  \|

The location of the point relative to the cone will be determined by the angle between the axis and the straight like connecting the vertex with this point; and the angle is defined by two catheti you can easily find out. Don't forget to consider "pathological" cases when cotangents can give you NaN, or atan2, if your library has it.

—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 22 Sep 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100