我正在围绕一个球体发射一个射弹。我的代码以逆时针方向移动它就好了。但是,我希望它改为顺时针方向移动。
我猜这是调整我的数学的问题。
// these are my stepping and incrementing variables
int goose1_egg1_step = 1;
int &r_goose1_egg1_step = goose1_egg1_step;
float goose1_egg1_divider = 17500;
// the starting theta/phi values are: 5 and 5
int goose1_egg1_theta=5;
int goose1_egg1_phi=5;
// the ending theta/phi values are: 7 and 1
// there is a difference of 2 between the start and end theta values
// there is a difference of 4 between the start and end phi values
float goose1_egg1_theta_increment = 2/goose1_egg1_divider;
float goose1_egg1_phi_increment = 4/goose1_egg1_divider;
这是我的函数,它用球体显示每帧的更新坐标:
if (goose1_egg1_step < goose1_egg1_divider)
{
float goose1_egg1_theta_math = (goose1_egg1_theta+(goose1_egg1_theta_increment* r_goose1_egg1_step))/10.0*M_PI;
float goose1_egg1_phi_math = (goose1_egg1_phi-(goose1_egg1_phi_increment* r_goose1_egg1_step))/10.0*2*M_PI;
r_goose1_egg1_x = Radius * sin(goose1_egg1_theta_math) * cos(goose1_egg1_phi_math);
r_goose1_egg1_y = Radius * sin(goose1_egg1_theta_math) * sin(goose1_egg1_phi_math);
r_goose1_egg1_z = Radius * cos(goose1_egg1_theta_math);
glPushMatrix();
glTranslatef(r_goose1_egg1_x,r_goose1_egg1_y,r_goose1_egg1_z);
glColor3f (1.0, 0.0, 0.0);
glutSolidSphere (0.075,5,5);
glEnd();
glPopMatrix();
}
这是我增加步长值的方法:
if (r_goose1_egg1_step < goose1_egg1_divider)
{
++(r_goose1_egg1_step);
}
else
r_goose1_egg1_step=1;