Cell[CellGroupData[{Cell[BoxData[ RowBox[{ RowBox[{"M1", "=", "5"}], ";"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.392304212921875*^9, 3.392304217109375*^9}, 3.39230429834375*^9, {3.392304535765625*^9, 3.39230454771875*^9}, 3.7607360918781033`*^9}, CellID->277034682], Cell[BoxData[ RowBox[{ RowBox[{"MinRad", "=", "5"}], ";"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.392304212921875*^9, 3.392304217109375*^9}, 3.39230429834375*^9, {3.392304535765625*^9, 3.392304539703125*^9}, 3.760736091878314*^9}, CellID->734224048], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "return", " ", "the", " ", "positions", " ", "and", " ", "velocities", " ", "of", " ", "the", " ", "particles"}], " ", "*)"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.4253381899291697`*^9, 3.4253382269447947`*^9}, 3.760736091878508*^9}, CellID->391831164], Cell[BoxData[ RowBox[{ RowBox[{"posandvel", "[", RowBox[{ RowBox[{"{", RowBox[{"a_", ",", "b_", ",", "c_"}], "}"}], ",", RowBox[{"{", RowBox[{"r_", ",", "dr_"}], "}"}], ",", "m_"}], "]"}], ":=", " ", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "xp", ",", "yp", ",", "pos", ",", "unitvel", ",", "vel", ",", "xandy"}], "}"}], ",", " ", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"xp", ",", "yp"}], "}"}], "=", RowBox[{"norms", "[", RowBox[{"{", RowBox[{"a", ",", "b", ",", "c"}], "}"}], "]"}]}], ";", " ", RowBox[{"xandy", "=", RowBox[{"Select", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"-", "r"}], ",", "r", ",", "dr"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"-", "r"}], ",", "r", ",", "dr"}], "}"}]}], "]"}], ",", "1"}], "]"}], ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"MinRad", "^", "2"}], "<", RowBox[{"(", RowBox[{"#", ".", "#"}], ")"}], "<", RowBox[{"r", "^", "2"}]}], ")"}], "&"}]}], "]"}]}], ";", " ", RowBox[{"pos", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"xp", " ", RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}]}], "+", RowBox[{"yp", " ", RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}]}]}], ")"}], "&"}], ",", "xandy"}], "]"}]}], ";", " ", RowBox[{"unitvel", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"-", RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}]}], " ", "yp"}], "+", RowBox[{ RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}], " ", "xp"}]}], ")"}], "/", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}], "^", "2"}], "+", RowBox[{ RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}], "^", "2"}]}], "]"}]}], ")"}], "&"}], ",", "xandy"}], "]"}]}], ";", " ", RowBox[{"vel", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "1", "]"}], "]"}], "*", RowBox[{"Sqrt", "[", RowBox[{"m", "/", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}], ".", RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}], "]"}]}], "&"}], ",", RowBox[{"Transpose", "[", RowBox[{"{", RowBox[{"unitvel", ",", "pos"}], "}"}], "]"}]}], "]"}]}], ";", " ", RowBox[{"{", RowBox[{"pos", ",", "vel"}], "}"}]}]}], "]"}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.392304212921875*^9, 3.392304217109375*^9}, 3.39230429834375*^9, {3.392304535765625*^9, 3.392304537359375*^9}, 3.7607360918786917`*^9}, CellID->3619984], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "calculate", " ", "the", " ", "normal", " ", "vectors", " ", "to", " ", "the", " ", "velocities"}], " ", "*)"}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.4253382520385447`*^9, 3.4253382662260447`*^9}, 3.760736091878888*^9}, CellID->14536935], Cell[BoxData[ RowBox[{ RowBox[{"norms", "[", RowBox[{"{", RowBox[{"x_", ",", RowBox[{"0", "|", "0."}], ",", RowBox[{"0", "|", "0."}]}], "}"}], "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], "}"}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.392223106*^9, 3.392223108859375*^9}, { 3.392301825515625*^9, 3.392301826640625*^9}, 3.3923042965*^9, 3.76073609187908*^9}, CellID->73281302], Cell[BoxData[ RowBox[{ RowBox[{"norms", "[", "v_List", "]"}], ":=", " ", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "w", ",", "u", ",", "wy", ",", "wz", ",", "ux", ",", "uy", ",", "uz"}], "}"}], ",", " ", RowBox[{ RowBox[{"w", "=", RowBox[{"{", RowBox[{"0", ",", "wy", ",", "wz"}], "}"}]}], ";", " ", RowBox[{"u", "=", RowBox[{"{", RowBox[{"ux", ",", "uy", ",", "uz"}], "}"}]}], ";", " ", RowBox[{"w", "=", RowBox[{"w", "/.", RowBox[{"First", "[", RowBox[{"NSolve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"w", ".", "v"}], "==", "0"}], ",", RowBox[{ RowBox[{"w", ".", "w"}], "==", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"wy", ",", "wz"}], "}"}]}], "]"}], "]"}]}]}], ";", " ", RowBox[{"u", "=", RowBox[{"u", "/.", RowBox[{"First", "[", RowBox[{"NSolve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"u", ".", "v"}], "==", "0"}], ",", RowBox[{ RowBox[{"u", ".", "w"}], "==", "0"}], ",", RowBox[{ RowBox[{"u", ".", "u"}], "==", "1"}]}], "}"}], ",", "u"}], "]"}], "]"}]}]}], ";", " ", RowBox[{"{", RowBox[{"w", ",", "u"}], "}"}]}]}], "]"}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.392223106*^9, 3.392223108859375*^9}, 3.392301825515625*^9, 3.392304294734375*^9, {3.392304614234375*^9, 3.392304616953125*^9}, 3.760736091879273*^9}, CellID->58814723], Cell[BoxData[ RowBox[{ RowBox[{"CenterOfMass", "[", RowBox[{ RowBox[{"{", RowBox[{"X1_", ",", "Y1_", ",", "Z1_"}], "}"}], ",", RowBox[{"{", RowBox[{"X2_", ",", "Y2_", ",", "Z2_"}], "}"}], ",", RowBox[{"{", RowBox[{"M1_", ",", "M2_"}], "}"}]}], "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"M1", " ", "X1"}], "+", RowBox[{"M2", " ", "X2"}]}], ")"}], "/", RowBox[{"(", RowBox[{"M1", "+", "M2"}], ")"}]}], ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"M1", " ", "Y1"}], "+", RowBox[{"M2", " ", "Y2"}]}], ")"}], "/", RowBox[{"(", RowBox[{"M1", "+", "M2"}], ")"}]}], ",", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"M1", " ", "Z1"}], "+", RowBox[{"M2", " ", "Z2"}]}], ")"}], "/", RowBox[{"(", RowBox[{"M1", "+", "M2"}], ")"}]}]}], "}"}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.392223106*^9, 3.392223109859375*^9}, 3.39230429340625*^9, 3.7607360918794613`*^9}, CellID->15994169], Cell[BoxData[ RowBox[{ RowBox[{"Initialize", "[", RowBox[{ "Dist_", ",", "MF_", ",", "XX1_", ",", "XX2_", ",", "pos_", ",", "pos2_", ",", "vel_", ",", "vel2_", ",", "V1_", ",", "V2_", ",", "ss_", ",", "tcol_", ",", "icol_", ",", "vp_", ",", "TIME_", ",", "ir_", ",", "tr_", ",", "sep_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "Rad1", ",", "Rad2", ",", "dr", ",", "intpl", ",", "Distlocal", ",", "MFlocal", ",", "M2local", ",", "poslocal", ",", "pos2local", ",", "vellocal", ",", "vel2local", ",", "XX1local", ",", "XX2local", ",", "V1local", ",", "V2local", ",", "sslocal", ",", "tcollocal", ",", "icollocal", ",", "vplocal", ",", "TIMElocal"}], "}"}], ",", " ", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ "Distlocal", ",", "Rad1", ",", "Rad2", ",", "dr", ",", "MFlocal", ",", "XX2local", ",", "V2local", ",", "intpl", ",", "sslocal", ",", "tcollocal", ",", "icollocal", ",", "vplocal", ",", "TIMElocal"}], "}"}], "=", RowBox[{"{", RowBox[{ "100", ",", "tr", ",", "ir", ",", "sep", ",", "MF", ",", "XX2", ",", "V2", ",", "Automatic", ",", ".001", ",", "Green", ",", "Cyan", ",", RowBox[{"{", RowBox[{"1.3", ",", RowBox[{"-", "2.4"}], ",", "2."}], "}"}], ",", "0"}], "}"}]}], ";", " ", RowBox[{"intpl", "=", "V2local"}], ";", " ", RowBox[{"(*", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"intpl", "===", "Automatic"}], ",", RowBox[{"intpl", "=", "V2local"}]}], "]"}], ";"}], "*)"}], " ", RowBox[{"XX1local", "=", RowBox[{"V1local", "=", RowBox[{"{", RowBox[{"0.", ",", "0.", ",", "0."}], "}"}]}]}], ";", " ", RowBox[{"M2local", "=", RowBox[{"MFlocal", " ", "M1"}]}], ";", " ", RowBox[{ RowBox[{"{", RowBox[{"poslocal", ",", "vellocal"}], "}"}], "=", RowBox[{"posandvel", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"Rad1", ",", "dr"}], "}"}], ",", "M1"}], "]"}]}], ";", " ", RowBox[{ RowBox[{"{", RowBox[{"pos2local", ",", "vel2local"}], "}"}], "=", RowBox[{"posandvel", "[", RowBox[{"intpl", ",", RowBox[{"{", RowBox[{"Rad2", ",", "dr"}], "}"}], ",", "M2local"}], "]"}]}], ";", " ", RowBox[{"pos2local", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"#", "+", "XX2"}], ")"}], "&"}], ",", "pos2local"}], "]"}]}], ";", " ", RowBox[{"vel2local", "=", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"#", "+", "V2"}], ")"}], "&"}], ",", "vel2local"}], "]"}]}], ";", " ", RowBox[{"{", RowBox[{ "Distlocal", ",", "MFlocal", ",", "V1local", ",", "V2local", ",", "sslocal", ",", "tcollocal", ",", "icollocal", ",", "vplocal", ",", "TIMElocal", ",", RowBox[{"Sequence", "@@", RowBox[{"Realign", "[", RowBox[{ "XX1local", ",", "XX2local", ",", "M2local", ",", "poslocal", ",", "pos2local"}], "]"}]}], ",", "vellocal", ",", "vel2local"}], "}"}]}]}], " ", "]"}]}]], "Input", CellGroupingRules->{"GroupTogetherGrouping", 10000.}, InitializationCell->True, CellChangeTimes->{ 3.35696210375764*^9, {3.392222995796875*^9, 3.39222305728125*^9}, { 3.392223954515625*^9, 3.392223956328125*^9}, {3.392224275015625*^9, 3.392224310046875*^9}, {3.39222447325*^9, 3.392224474375*^9}, { 3.39222453375*^9, 3.392224583390625*^9}, {3.392224898890625*^9, 3.39222489940625*^9}, {3.39222497640625*^9, 3.392225008640625*^9}, {3.39222507975*^9, 3.39222513703125*^9}, { 3.39222517665625*^9, 3.392225257*^9}, {3.392225360828125*^9, 3.392225390328125*^9}, {3.392225452625*^9, 3.3922254939375*^9}, 3.392226594453125*^9, {3.392226772484375*^9, 3.392226862171875*^9}, {3.392226983203125*^9, 3.392227005734375*^9}, {3.3922270691875*^9, 3.392227085125*^9}, { 3.392227215734375*^9, 3.392227217640625*^9}, {3.39222726115625*^9, 3.3922272633125*^9}, {3.392302600921875*^9, 3.3923026213125*^9}, { 3.392302661171875*^9, 3.39230266265625*^9}, {3.392302725265625*^9, 3.392302751515625*^9}, {3.392303053421875*^9, 3.392303247109375*^9}, {3.392303325828125*^9, 3.39230332975*^9}, { 3.39230338325*^9, 3.39230338390625*^9}, {3.39230367271875*^9, 3.392303677546875*^9}, 3.392304289890625*^9, {3.392304406390625*^9, 3.3923044071875*^9}, {3.39230504825*^9, 3.392305248828125*^9}, { 3.3923219015*^9, 3.392321904828125*^9}, {3.39232501290625*^9, 3.392325025359375*^9}, {3.39232521409375*^9, 3.392325214734375*^9}, {3.39232524890625*^9, 3.392325251578125*^9}, {3.392325285765625*^9, 3.3923252863125*^9}, {3.392576657140625*^9, 3.392576670609375*^9}, {3.39257842209375*^9, 3.392578428984375*^9}, 3.392578480515625*^9, {3.39258279128125*^9, 3.392582799078125*^9}, {3.392582884640625*^9, 3.39258288509375*^9}, {3.392584280671875*^9, 3.392584290625*^9}, { 3.392584424109375*^9, 3.392584437203125*^9}, {3.392584647015625*^9, 3.39258466915625*^9}, {3.392584809546875*^9, 3.392584812625*^9}, { 3.39258535303125*^9, 3.392585353734375*^9}, {3.392585520421875*^9, 3.392585541859375*^9}, {3.3925859188125*^9, 3.392585919234375*^9}, {3.39258657240625*^9, 3.39258657371875*^9}, {3.392586651828125*^9, 3.392586652546875*^9}, {3.392586785546875*^9, 3.392586791953125*^9}, 3.760736091879633*^9}, CellID->319048679], Cell[BoxData[ RowBox[{ RowBox[{"Draw", "[", RowBox[{ "XX1_", ",", "XX2_", ",", "MF_", ",", "pos_", ",", "pos2_", ",", "Dist_", ",", "TIME_", ",", "vp_", ",", "ss_", ",", "tcol_", ",", "icol_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"cm", "=", RowBox[{"CenterOfMass", "[", RowBox[{"XX1", ",", "XX2", ",", RowBox[{"{", RowBox[{"M1", ",", RowBox[{"M1", "*", "MF"}]}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"Graphics3D", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"tcol", ",", RowBox[{"PointSize", "[", "ss", "]"}], ",", RowBox[{"Point", "[", "pos", "]"}], ",", RowBox[{"PointSize", "[", ".025", "]"}], ",", RowBox[{"Point", "[", "XX1", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"icol", ",", RowBox[{"PointSize", "[", "ss", "]"}], ",", RowBox[{"Point", "[", "pos2", "]"}], ",", RowBox[{"PointSize", "[", ".025", "]"}], ",", RowBox[{"Point", "[", "XX2", "]"}]}], "}"}]}], "}"}], ",", RowBox[{"BaseStyle", "->", RowBox[{"{", RowBox[{"GrayLevel", "[", "1", "]"}], "}"}]}], ",", RowBox[{"AxesStyle", "->", RowBox[{"GrayLevel", "[", ".5", "]"}]}], ",", RowBox[{"BoxStyle", "->", RowBox[{"GrayLevel", "[", ".5", "]"}]}], ",", RowBox[{"PlotRange", "->", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "Dist"}], "+", RowBox[{"cm", "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", RowBox[{"Dist", "+", RowBox[{"cm", "[", RowBox[{"[", "1", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "Dist"}], "+", RowBox[{"cm", "[", RowBox[{"[", "2", "]"}], "]"}]}], ",", RowBox[{"Dist", "+", RowBox[{"cm", "[", RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "Dist"}], "+", RowBox[{"cm", "[", RowBox[{"[", "3", "]"}], "]"}]}], ",", RowBox[{"Dist", "+", RowBox[{"cm", "[", RowBox[{"[", "3", "]"}], "]"}]}]}], "}"}]}], "}"}]}], ",", RowBox[{"Axes", "->", "True"}], ",", RowBox[{"ViewPoint", "->", "vp"}], ",", RowBox[{"Background", "->", RowBox[{"GrayLevel", "[", "0", "]"}]}], ",", RowBox[{"PlotLabel", "->", RowBox[{"\"\