我有这张图片:
我不知道它到底是什么类型的投影,我猜是等角的还是墨卡托的。它是an attitude indicator,b的纹理。在
我想画一个orthographic projection,b或者一个General Perspective projection(哪一个看起来更好)根据一个由两个角度(航向和俯仰)定义的方向向量。这个方向定义了球体上的一个点,这个点应该是投影的中心。在
我想让它从飞行员的角度看,所以只能画出球体的一半。在
我使用python,我还没有选择图形库,但我可能会使用pygame。在
我发现了一些相关的东西:http://www.pygame.org/project-Off-Center+Map+Projections-2881-.html但是它使用OpenGL,我没有使用它的经验,但是如果需要,我可以尝试一下。在
我该怎么做?我可能可以通过计算公式计算每个像素来手动绘制它,但我认为有一些库工具可以有效地实现这一点(可能是硬件加速?)。在
对于全Python解决方案(使用numpy/scipy array ops,这将比任何显式的每像素循环都快),它:
会得到你的
。在
尽管如此,OpenGL确实是一个进行这种像素争夺的地方,尤其是对于任何交互式的东西。在
我看了看你链接的“偏心地图投影”里的代码。。。在
作为一个起点,我想说这是非常好的,特别是如果你想在PyGame中以任何形式的效率实现这一点,因为将任何类型的每像素操作卸载到OpenGL上都将比Python中的速度快得多。在
显然,要进一步了解OpenGL,投影是用
main.py
的GLSL代码(字符串中传递给mod_program.ShaderFragment
)的GLSL代码实现的,如果您阅读过等矩形投影,那么atan和asin就不应该感到惊讶了。在但是,要达到你想要的效果,你必须弄清楚如何渲染球体而不是视口填充四边形(在主.py在
glBegin(GL_QUADS);
)。或者,继续使用屏幕填充四边形并在着色器代码中执行光线球体交集(这实际上就是我另一个答案中的python代码所做的)。在相关问题 更多 >
编程相关推荐