Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (1 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
Comments
Sergey Alexandrovich Kryukov 22-Sep-14 2:41am    
Please, where is your problem, in middle school mathematics? Just a hint: this is a simple 2D problem.
—SA

1 solution

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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900