13,663,621 members
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

Please, where is your problem, in middle school mathematics? Just a hint: this is a simple 2D problem.
—SA

## 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

Top Experts
Last 24hrsThis month
 OriginalGriff 285 F-ES Sitecore 145 Gerry Schmitz 105 Vincent Maverick Durano 75 Member 13948830 50
 OriginalGriff 3,442 Richard MacCutchan 1,367 ppolymorphe 1,277 Jochen Arndt 1,212 Dave Kreskowiak 773