如何检测点是否在3d圆锥内 [英] How to detect if a point is inside a 3d cone

查看:99
本文介绍了如何检测点是否在3d圆锥内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须写下一个程序,它将3d中的一个点作为输入并告诉该点是否在3d锥内?

解决方案

更多的一个提示:



这是一个简单的二维问题。我假设这是一个基于圆的圆锥体。通过穿过轴的平面剖析锥体。考虑这个问题。您将获得由此轴形成的两个对称矩形,并与锥面相交,具有公共顶点。从所讨论的点垂直下降到轴:

 / | 
/ | *?
/ __ | ___ |
\ |
\ |
\ |



点相对于圆锥的位置将由轴和直线之间的角度确定,就像连接顶点和此点一样;并且角度由两个导管定义,您可以轻松找到。如果您的图书馆拥有NaN或atan2,请不要忘记考虑病态案例。



-SA

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 ?

解决方案

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


这篇关于如何检测点是否在3d圆锥内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆