Note that there are some explanatory texts on larger screens.

plurals
  1. POincrementing my spherical coordinates clockwise
    primarykey
    data
    text
    <p>I am launching a projectile around a sphere. My code moves it in a counterclockwise direction just fine. However, I would like it to move in a clockwise direction instead.</p> <p>I'm guessing that it's a matter of tuning my math.</p> <pre><code>// these are my stepping and incrementing variables int goose1_egg1_step = 1; int &amp;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; </code></pre> <p>This is my function that displays the updated coordinates each frame with a sphere:</p> <pre><code>if (goose1_egg1_step &lt; 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(); } </code></pre> <p>And here is how I increment the step value:</p> <pre><code>if (r_goose1_egg1_step &lt; goose1_egg1_divider) { ++(r_goose1_egg1_step); } else r_goose1_egg1_step=1; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload