从球面到宪章的坐标进行射线投射 [英] spherical to chartezian coordinates for ray casting

查看:121
本文介绍了从球面到宪章的坐标进行射线投射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好:)

给定相机角度,并要求它计算从每个像素出来的光线的方向(光线投射算法).屏幕中间的光线与照相机的方向相同,并且当光线朝屏幕的末端传播时,它们会散开(它们形成类似金字塔的形状).

射线的方向应为直角坐标,相对于i,j,k.

到目前为止:
在摄影机角度之上必须添加到每条光线的角度:

Hi there:)

A camera angle is given and it is asked to calculate the direction of the rays coming out of each pixel (ray casting algorithm). The ray at the middle of the screen has the same direction as the camera and as the rays go toward the extremities of the screen, they spread out (they form something like a pyramid).

The direction of the rays should be in cartesian coordinates, versors i, j, k.

So far:
the angle that has to be added to each ray, on top of the camera angle:

ray_angle.x = Camera.fov * i/height - Camera.fov/2;
ray_angle.y = Camera.fov * j/width - Camera.fov/2;



fov =摄像机的视野(金字塔顶端的角度)



fov=field of view of the camera (angle at the tip of the pyramid)

ray_angle.x = ray_angle.x + Camera.rotx;
ray_angle.y = ray_angle.z + Camera.roty;



以及对i,j,k的更改:



and the change to i,j,k:

ray_direction.i=sin(ray_angle.x)*cos(ray_angle.y);
ray_direction.j=sin(ray_angle.x)*sin(ray_angle.y);
ray_direction.k=cos(ray_angle.x);




那根本不起作用...
在图像中转换的方向如下所示:

i:




and that doesn''t work at all...
the directions converted in images look like this:

i:

---------------]
-`````````````-]
*-```````````-*]
-``````-``````-]
``````-*-``````]
```````-```````]
---------------]


j:


j:

---------------]
``-````````````]
`-*-```````````]
``-```````-````]
`````````-*-```]
``````````-````]
---------------]


k:


k:

---------------]
```````````````]
-`-`-`-`-`-`-`-]
*`*`*`*`*`*`*`*]
-`-`-`-`-`-`-`-]
```````````````]
---------------]



-*-=从各个像素发出的光线的较大值.图像是渐变的.

你能帮我吗?我不擅长数学.

谢谢:)



-*- = greater values for the ray emerging from the respective pixels. The images are in gradients.

Can you help me with this? I''m not to good at maths.

Thank you :)

推荐答案

仍然无法正常工作...
视野是360,所以是一个完整的球体.

我应该像个X,侧面的三角形变亮,顶部的三角形变暗,渐变. j像单杠一样,中间是黑暗的,顶部和底部是亮的. k更复杂:
00000
01010
14141
01010
00000

你可以帮忙吗?

光线投射的结果大约是4个圆圈,在所有圆圈中都可以看到相同的场景片段,但是方向不同(镜像,旋转).随着位置的变化,一些球体逐渐增大,其他球体缩小直到它们的位置发生变化,它们彼此接触,并在相交处可以看到场景的另一部分.
still not working...
The fov is 360, so a complete sphere.

the i should be like a X, the triangles in the sides lighter and the ones at the top darker, in gradient. j like a horizontal bar, dark at the center and lit at the top and bottom. k more complicated:
00000
01010
14141
01010
00000

can you help with this?

the ray cast result is something like 4 circles, there can be seen the same fragment of the scene in all of them, but with different orientations (mirrored, rotated). As the position changes some spheres grow, other deflate until their position changes, they touch one another and at the intersection, another part of the scene can be seen.


这篇关于从球面到宪章的坐标进行射线投射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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