OpenGL绘图地球如何缩放点

时间:2014-01-15 23:29:18

标签: opengl math

我有问题,因为我想在球体上绘制点,但我不知道如何正确地缩放它们。

R = 6400km <- R of earth
r = 6400m <- r of earth in my program
w = r/R;

每个点都有h。 x = lattitude,y = longtitude

我的问题是身高。你能告诉我我的错误。

 x = (r+h*w) * cos(x *  PI / 180.0) * cos(y * PI / 180.0)
 y = (r+h*w)* cos(x *  PI / 180.0) * sin(y * PI / 180.0)
 z = (r+h*w) *sin(x * PI / 180.0) 

这就是我设定w = 0.01时的情况。当我设置w = r / R时,我只看到人工制品 img

2 个答案:

答案 0 :(得分:3)

它应该是这样的:

x=scale*(re+h)*cos(a)*cos(b);
y=scale*(re+h)*cos(a)*sin(b);
z=scale*(rp+h)*sin(a);
  • 重赤道半径
  • rp - 极半径
  • h - 身高
  • a&lt; -0.5 * PI,+ 0.5 * PI&gt;
  • b&lt; 0,2.0 * PI&gt;

你的身高缩放似乎没问题可能

  • 没有括号(有些编译器在没有适当包围的情况下弄得一团糟)
  • 错误的PI ...通常数学定义:M_PI
  • cos,sin处理通常是弧度,但我也看到了一些库中的度数,确保什么是适合你的
  • 错误的角度间隔

究竟出了什么问题?图片或更多详细信息将有所帮助

答案 1 :(得分:0)

看看你有什么向量似乎是在正确的方向。我不确定你为什么要乘以w,不要只是想要

x = (r+h) * cos(latitude * PI / 180.0) * cos(longitude * PI / 180.0)
y = (r+h) * cos(latitude * PI / 180.0) * sin(longitude * PI / 180.0)
z = (r+h) * sin(latitude * PI / 180.0)