使用球坐标,我在球体表面周围画了一条弧线。这是我的代码:
int goose1a_egg1_step = 0; // THIS IS INCREMENTED EACH FRAME
float goose1a_egg1_theta=7.5; // START THETA
float goose1a_egg1_phi=4; // START PHI
float goose1a_egg1_theta_increment = 1.5/goose1a_egg1_divider; // END THETA = 6
float goose1a_egg1_phi_increment = 3/goose1a_egg1_divider; // END PHI = 1
float goose1a_egg1_theta_math1 = (goose1a_egg1_theta-(goose1a_egg1_theta_increment* r_goose1a_egg1_step))/10.0*M_PI;
float goose1a_egg1_phi_math1 = (goose1a_egg1_phi-(goose1a_egg1_phi_increment* r_goose1a_egg1_step))/10.0*2*M_PI;
r_goose1a_egg1_x = radius_egg_pos * sin(goose1a_egg1_theta_math1) * cos(goose1a_egg1_phi_math1);
r_goose1a_egg1_y = radius_egg_pos * sin(goose1a_egg1_theta_math1) * sin(goose1a_egg1_phi_math1);
r_goose1a_egg1_z = radius_egg_pos * cos(goose1a_egg1_theta_math1);
glPushMatrix();
glTranslatef(r_goose1a_egg1_x,r_goose1a_egg1_y,r_goose1a_egg1_z);
glColor3f (1, 1, .8);
glutSolidSphere (0.02,5,5);
glEnd();
glPopMatrix();
我想画一条额外的弧线,它具有相同的 START 和 END 位置。关键是,与其让第二个弧线遵循与第一个完全相同的轨迹,我可以调整我的数学以使弧线存在可变性吗?例如,第二条弧线的运行路径与第一条弧线略有不同。就像两个航班离开 DFW 前往 JFK,但路线略有不同。
第二个弧的代码如下(注意:两者之间的唯一区别是“goose1a”和“goose1b” - 我不想在这里添加一堆杂乱无章的东西,其中我是随机将随机变量乘以随机整数:/)
int goose1b_egg1_step = 0; // THIS IS INCREMENTED EACH FRAME
float goose1b_egg1_theta=7.5; // START THETA
float goose1b_egg1_phi=4; // START PHI
float goose1b_egg1_theta_increment = 1.5/goose1b_egg1_divider; // END THETA = 6
float goose1b_egg1_phi_increment = 3/goose1b_egg1_divider; // END PHI = 1
float goose1b_egg1_theta_math1 = (goose1b_egg1_theta-(goose1b_egg1_theta_increment* r_goose1b_egg1_step))/10.0*M_PI;
float goose1b_egg1_phi_math1 = (goose1b_egg1_phi-(goose1b_egg1_phi_increment* r_goose1b_egg1_step))/10.0*2*M_PI;
r_goose1b_egg1_x = radius_egg_pos * sin(goose1b_egg1_theta_math1) * cos(goose1b_egg1_phi_math1);
r_goose1b_egg1_y = radius_egg_pos * sin(goose1b_egg1_theta_math1) * sin(goose1b_egg1_phi_math1);
r_goose1b_egg1_z = radius_egg_pos * cos(goose1b_egg1_theta_math1);
glPushMatrix();
glTranslatef(r_goose1b_egg1_x,r_goose1b_egg1_y,r_goose1b_egg1_z);
glColor3f (1, 1, .8);
glutSolidSphere (0.02,5,5);
glEnd();
glPopMatrix();
因为我对 3D 数学的理解太差了,我什至不确定是否有办法做到这一点?如果没有,我会为我的设计寻找替代解决方案。但是,如果可以使用球坐标绘制两条使用相同 START 和 END 位置的不同弧线,我们将不胜感激您的建议和指导。