Domanda

so i am trying to change the angle at which the object orbits in relation to the x-axis as you are looking down the z-axis. see the picture for what i mean: Angles

i am currently using this code to orbit the two red spheres:

public void orbit() {
    theta += this.vel.x;
    theta = fixAngle(theta, TWO_PI);

    this.loc.x = this.origin.x+orbitRadius*cos(theta);
    this.loc.y = this.origin.y+orbitRadius*cos(theta);
    this.loc.z = this.origin.z+orbitRadius*sin(theta);
  }

  private float fixAngle(float ang, float range) {
    if (ang < 0)
      ang += range;
    else if (ang > range)
      ang -= range;
    return ang;
  }

does anyone know how i can accomplish this?

È stato utile?

Soluzione

apparently it can be done by not rotating the orbiting object but by rotating the coordinate system as answered HERE

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top