From 5329a899afbc5209bda126206bb337fa81e2faa8 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 13 Jan 2023 18:12:51 -0500 Subject: [PATCH] Put the CoM back as the reference frame for the fragmentation movies --- examples/Fragmentation/Fragmentation_Movie.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/Fragmentation/Fragmentation_Movie.py b/examples/Fragmentation/Fragmentation_Movie.py index a77156d66..9c3e3bc56 100755 --- a/examples/Fragmentation/Fragmentation_Movie.py +++ b/examples/Fragmentation/Fragmentation_Movie.py @@ -38,7 +38,7 @@ available_movie_styles = ["disruption_headon", "disruption_off_axis", "supercatastrophic_headon", "supercatastrophic_off_axis","hitandrun_disrupt", "hitandrun_pure", "merge"] movie_title_list = ["Head-on Disruption", "Off-axis Disruption", "Head-on Supercatastrophic", "Off-axis Supercatastrophic", "Hit and Run w/ Runner Disruption", "Pure Hit and Run", "Merge"] movie_titles = dict(zip(available_movie_styles, movie_title_list)) -num_movie_frames = 1200 +num_movie_frames = 1000 # These initial conditions were generated by trial and error names = ["Target","Projectile"] @@ -206,9 +206,17 @@ def update_plot(self, frame): def reference_frame(r_ref, v_ref, t): coord_pos = r_ref + v_ref * t return coord_pos.values[0], coord_pos.values[1] + + def center(Gmass, x, y): + x = x[~np.isnan(x)] + y = y[~np.isnan(y)] + Gmass = Gmass[~np.isnan(Gmass)] + x_com = np.sum(Gmass * x) / np.sum(Gmass) + y_com = np.sum(Gmass * y) / np.sum(Gmass) + return x_com, y_com t, Gmass, rh, point_rad = next(self.data_stream(frame)) - x_ref, y_ref = reference_frame(self.r_ref,self.v_ref, t) + x_ref, y_ref = center(Gmass, rh[:,0], rh[:,1]) self.scatter_artist.set_offsets(np.c_[rh[:,0] - x_ref, rh[:,1] - y_ref]) self.scatter_artist.set_sizes(point_rad**2) return self.scatter_artist,