如何有效计算球体上的可见点?

发布于 2025-01-24 13:34:46 字数 798 浏览 1 评论 0原文

我有很多小点可以在球体的表面上绘制。它们由两个角度lat∈[-pi/2,pi/2]long∈[-pi,pi]和相同的半径r < /代码>。

我的相机直接指向球体的中心,也位于角度和长度。但是,它与中心的距离可能会有所不同,但总是大于r,我们称其为d

对于每个可见点,除了实际的渲染外,我还必须进行其他计算,因此,为了使动画循环更快,我想知道哪些是可见的,哪些是什么。

我尝试过的是:

如果此条件为真,则不要渲染它们:Math.abs(point.position.long- camera.position.position.long)&gt; Math.pi/4&amp;&amp; Math.Abs​​(point.position.lat -camera.position.lat)&gt; Math.pi/4

仅在摄像机的纬度为0时起作用,因为如果您在杆上,您想看到的纵向范围实际上是2*Pi,但您希望减少纬度范围。

然后,我尝试通过使用Math.pi/4 + 3/2*Math.abs(this.Rotation.lat)而不是仅仅是MATH MATH来计算经度范围时考虑了纬度。 pi/4,它更好,但仍然不完美。

我想知道如何实现这一目标,在最好的情况下,请考虑到相机的设置,也许使用其投影或模型视图矩阵(我使用three.js,因此可以随时可用)来真正减少点渲染。

多谢,

I have a lot of small points to draw on the surface of a sphere. They are located by two angles lat ∈ [-PI/2,PI/2] and long ∈ [-PI,PI] and the same radius R.

My camera is pointing directly at the center of the sphere, and is also located with angles lat and long. Its distance from the center can vary though, but is always greater than R, let's call it d.

For each visible points, I have to make other calculations in addition to the actual rendering, so to make the animation loop faster I would like to know which ones are visible and which ones are not.

What I have tried :

Don't render them if this condition is true : Math.abs(point.position.long - camera.position.long) > Math.PI/4 && Math.abs(point.position.lat - camera.position.lat) > Math.PI/4

Which only work when the camera's latitude is 0, because if you are at a pole the range of longitudes you want to see is actually 2*PI, but you want a reduced latitude range.

I then tried taking latitude into account when calculating the longitude range, by using Math.PI/4 + 3/2*Math.abs(this.rotation.lat) instead of just Math.PI/4 and it is better but still not perfect.

I would like to know how I could achieve this, and in the best case scenario take into account the camera's settings, maybe with its projection or model view matrices (I use THREE.js so they are readily available) to really reduce the number of points rendered.

Thanks a lot,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文