N = 30  # number of bodies

    m0 = 25  # kg. The first mass
    pos0 = vector(0, 0, 0)  # it starts from the center
    v0 = vector(0, 0, 0)  # it is at rest

    masses = [m0]  # list of masses, initialized with the first element
    initial_positions = [pos0]
    initial_velocities = [v0]

    for idx in range(1, N):
        # Each body has the same mass
        masses.append(1)  # kg
        # Place the masses randomly in space
        initial_positions.append(vector.random())  # m
        # Give random initial velocities
        initial_velocities.append(vector.random())  # m/s

    sys = system(masses, initial_positions, initial_velocities, delta_t)

    # add a trace to the center of mass
    trace = sphere(radius=1e-2,
                   make_trail=True,
                   trail_type="points",
                   trail_radius=5e-3,
                   interval=15,
                   retain=50)

    while True:
N = 2000  # numero di particelle
particelle = []  # lista che conterrà tutte le particelle (sphere)

polline = sphere()
polline.mass = 2
polline.radius = 0.15
polline.pos = vector(0, 0, 0)
polline.velocity = vector(10, 0, 0)
polline.color = color.green
attach_trail(polline, radius=0.006, retain=70, pps=4, type='points')

for index in range(N):
    particella = sphere()
    particella.mass = 0.01
    particella.radius = 0.015
    particella.pos = vector.random()
    particella.velocity = vector.random()
    particella.color = color.orange
    particelle.append(particella)

# Disegna un cubo di lato 2d
d = 1  # semilato del cubo
r = 0.005
gray = color.gray(0.7)
boxbottom = curve(color=gray, radius=r)
boxbottom.append([
    vector(-d, -d, -d),
    vector(-d, -d, d),
    vector(d, -d, d),
    vector(d, -d, -d),
    vector(-d, -d, -d)
Created on Mon May  9 22:34:05 2020

@author: Andrea Bassi
"""
from vpython import scene, vector, curve, color, sphere, mag, rate, dot, cross, attach_trail

G = 1  # costante gravitazione

N = 10  # numero di corpi
bodies = []  # lista che conterrà tutti i corpi (sphere)

for index in range(N):
    body = sphere()
    body.mass = 0.5
    body.radius = 0.05
    body.pos = vector.random()
    body.velocity = vector.random()
    body.color = color.orange
    bodies.append(body)

dt = 0.005  # campionamento temporale

# sfera con traiettoria che useremo per mostrare il centro di massa
center_mass = sphere(radius=0.01,
                     make_trail=True,
                     trail_type="points",
                     trail_radius=0.001,
                     interval=20,
                     retain=50)

while True: