Currently, I am developing a simulation of the Saturn system that will enable users to manipulate variables such as increasing the mass of its largest moon, Titan, to match that of Earth. This adjustment will illustrate how other moons and rings are affected by the change in Titan's mass. In my simulation, I represent the rings using a basic particle system where each particle is initialized with x, y, z positions, and velocity vectors. While setting z position and velocity vectors to zero creates a visually pleasing ring orbiting Saturn, complications arise due to Saturn's 27-degree axial tilt.
The key function responsible for establishing the initial conditions of the ring particles is outlined below:
init() {
for (let i = 0; i < this.numberOfParticles; i++) {
const rad = Math.PI * 2 * Math.random();
const dist = (25 + 20 * Math.random()) / 32000;
this.particles.push({
x: Math.cos(rad) * dist,
y: Math.sin(rad) * dist,
z: 0,
vx: (Math.cos(rad + Math.PI / 2 + (Math.PI / 180 * 6 - Math.PI / 180 * 12) * 0) * Math.sqrt(500 / dist)) / 120,
vy: (Math.sin(rad + Math.PI / 2 + (Math.PI / 180 * 6 - Math.PI / 180 * 12) * 0) * Math.sqrt(500 / dist)) / 120,
vz: 0
});
}
}
I am currently seeking assistance from anyone able to guide me on properly adjusting the z position and velocity vectors according to the given code snippet. Considering the aforementioned axial tilt requirement of 27 degrees, I aim to ensure the accuracy of the ring's inclination.