changing the angle of an orbiting object in relation to the x-axis
in
Programming Questions
•
1 years ago
so i have an object rotating in 3d space around another object. i have it orbiting at an angle (45 deg from the -x axis it looks like). but i want to change the angle at which it orbits in relation to the x-axis, effectively making the orbit either more horizontal or more vertical while looking down the z-axis. does anyone know how to go about doing this? here is the code im using to do the orbit:
CODE:
- 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);
- println(loc);
- }
- private float fixAngle(float ang, float range) {
- if (ang < 0)
- ang += range;
- else if (ang > range)
- ang -= range;
- return ang;
- }
1