我的太阳系出了问题
problem with my Solar System
所以,这是我的问题。我应该建立一个以太阳为中心,行星围绕太阳旋转的太阳系;每个行星都应该有自己的卫星。
所以,我做了所有的,但我不能做地球自转。。。地球绕太阳旋转,月球绕地球旋转。。。我怎么能让地球自转呢?当我在代码中输入另一个"glrotating"命令时,月球从地球上坠落或发生了一些奇怪的事情。。。
下面是我的代码。。。
// EARTH
// INFO: 1) it's 3rd planet from the Sun;
// 2) it's 5th largest planet in the Solar System, with an equatorial radius of 6378.388km;
// 3) it's 3rd fastest planet, because its orbital period is of 365 earth-days (1 year).
void Earth(void)
{
DrawOrbit(5.5, 1);
glRotatef((GLfloat) year*6.2, 0.0, 1.0, 0.0); //orbital movement for the Earth around the Sun
glTranslatef(5.5, 0.0, 0.0);
glColor3f(0.0, 0.3, 1.0);
glutSolidSphere(0.28, 20, 10); //draw Earth: more or less, the Earth has got the same dimension of Venus.
// The Earth has got one natural satellites: the Moon. Let's draw it:
glPushMatrix();
glRotatef((GLfloat) day*2, 0.0, 1.0, 0.0); //rotate for the moon
glTranslatef(0.5, 0.0, 0.0);
glColor3f(1.0f, 1.0f, 1.0f);
glutSolidSphere(0.05, 5, 4); //draw moon: its diameter is about a quarter the diameter of Earth
glPopMatrix();
}
将地球更改为此
glPushMatrix();
glRotatef(earth_rotation);
glutSolidSphere(0.28, 20, 10); //draw Earth: more or less, the Earth has got the same dimension of Venus.
glPopMatrix();
天文学注意事项:地球实际上比金星略大。到目前为止,你们所有的轨道都是共面的。此外,地球自转轴相对于轨道平面(称为黄道)倾斜约23°。月球的轨道再次相对于黄道倾斜约5°。当然,行星绕太阳公转并不是完美的,而是椭圆曲线。
月球绕地球的公转与地球绕其自身轴线的自转无关(至少出于渲染目的)
所以你应该推矩阵旋转地球,弹出并使用你的月球逻辑。此外,如果你只是把地球画成一个实心球体,即使它绕着自己旋转,它也不会在你的应用程序中出现,除非你有一个漂亮的纹理
如果你想准确地做到这一点,坦率地说,你所做的是错误的。
这些行星并不完全围绕太阳运行。它们围绕太阳系重心运行,而太阳系重心恰好位于太阳表面之外。月球的质量约为地球的0.0123,这意味着你最好将地球和月球建模为绕其共同质心运行,而不是月球绕地球运行。
冥王星和卡戎也是如此,但嘿,冥王星已经不是一颗行星了,谁在乎呢?
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 编译包含字符串的代码时遇到问题
- Project Euler问题4的错误解决方案
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 一个关于在C++中重载布尔运算符的问题
- 首要问题的答案让值班员搞错了
- setlocale的C++土耳其字符串问题
- 如何重构类层次结构以避免菱形问题
- 基于boost的程序的静态链接——zlib问题
- 太阳系模拟器物理集成问题(虚幻引擎4,C++)
- 我的太阳系出了问题