I’m trying to figure out how to model the rings of Saturn using a particle system for a gravity simulator that I’m making. Using the code below, I’ve managed to create a, if not perfect, decent ring that rotates around Saturn under the force of the gravity of Saturn and its moons. However, my ring has an axial tilt of 0 whereas in reality the axial tilt of Saturn’s rings is 27 degrees. The problem is that I can’t get the z position and velocity vectors right for the particles that make up the particle system. Would anybody be able to help me figure out how to accomplish this? The code that I'm using to generate the initial state vectors for each particle in the ring can be found below.
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
});
}