立方到等矩形投影算法 [英] Cubic to equirectangular projection algorithm

查看:505
本文介绍了立方到等矩形投影算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个定义周围的立方体贴图纹理,但是我需要将它传递给仅适用于纬度/经度贴图的程序。我真的在这里迷失在如何做翻译。这里有什么帮助吗?

换句话说,我需要从这里来:



对此(我认为该图片有aditional -90°旋转):





update:我得到了投影的正式名称。顺便说一句,我找到了相反的投影这里

  

对于目标图像的每个像素:
计算三维空间中相应的单位向量
计算源图像中该向量的x,y坐标
在该坐标处对源图像进行采样并将值赋给目标像素

最后一步是插值。我们将关注其他两个步骤。



给定经度和纬度的单位矢量是(+ z朝向北极,+ x朝向素数子午线):

  x = cos(lat)* cos(lon)
y = cos(lat)* sin(lon)
z = sin(lat)

假设立方体在原点附近为+/- 1单位即2x2x2的整体尺寸)。
一旦我们有了单位矢量,我们可以通过查看具有最大绝对值的元素来找到它所在立方体的面。例如,如果我们的单位矢量<0.2099,-0.7289,0.6516>,那么y元素具有最大的绝对值。它是负面的,所以这个点将在立方体的-y面上找到。通过除以y的大小来标准化其他两个坐标以获得该脸部内的位置。所以,这一点将在x = 0.2879,z = 0.8939在-y脸上。


I have a cube map texture which defines a surrounding, however I need to pass it to a program which only works with latitude/longitude maps. I am really at lost here on how to do the translation. Any help here?

In other words, I need to come from here:

To this (I think that image has an aditional -90° rotation over the x axis):

update: I got the official names of the projections. By the way, I found the opposite projection here

解决方案

A general procedure for projecting raster images like this is:

for each pixel of the destination image:
    calculate the corresponding unit vector in 3-dimensional space
    calculate the x,y coordinate for that vector in the source image
    sample the source image at that coordinate and assign the value to the destination pixel

The last step is simply interpolation. We will focus on the other two steps.

The unit vector for a given latitude and longitude is (+z towards the north pole, +x towards the prime meridian):

x = cos(lat)*cos(lon)
y = cos(lat)*sin(lon)
z = sin(lat)

Assume the cube is +/- 1 unit around the origin (i.e. 2x2x2 overall size). Once we have the unit vector, we can find the face of the cube it's on by looking at the element with the largest absolute value. For example, if our unit vector was <0.2099, -0.7289, 0.6516>, then the y element has the largest absolute value. It's negative, so the point will be found on the -y face of the cube. Normalize the other two coordinates by dividing by the y magnitude to get the location within that face. So, the point will be at x=0.2879, z=0.8939 on the -y face.

这篇关于立方到等矩形投影算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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