00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "scatter3.h"
00012
00013
00014
00015
00016
00017 void set_orientation(kepler &k, phase3 &p)
00018 {
00019 real mu = p.cos_theta;
00020 real sin_theta = sqrt(1 - mu * mu);
00021
00022
00023
00024 vector n = vector(sin_theta*cos(p.phi), sin_theta*sin(p.phi), mu);
00025
00026
00027
00028 vector temp = vector(1, 0, 0);
00029 if (abs(n[0]) > .5) temp = vector(0, 1, 0);
00030 if (n[2] < 0) temp = -temp;
00031
00032 vector b = n ^ temp;
00033 b /= abs(b);
00034 vector a = b ^ n;
00035 if (n[2] < 0) a = -a;
00036
00037
00038
00039
00040 vector l = cos(p.psi)*a + sin(p.psi)*b;
00041 vector t = n ^ l;
00042
00043 k.set_orientation(l, t, n);
00044 k.initialize_from_shape_and_phase();
00045 }
00046
00047
00048
00049
00050
00051 sdyn3 * set_up_dynamics(real m2,
00052 real m3,
00053 kepler & k1,
00054 kepler & k3)
00055 {
00056
00057
00058 sdyn3 * b = mksdyn3(3);
00059
00060
00061
00062 b->set_time(k3.get_time());
00063 for_all_daughters(sdyn3, b, bb)
00064 bb->set_time(k3.get_time());
00065
00066 sdyn3 * b1 = b->get_oldest_daughter();
00067 sdyn3 * b2 = b1->get_younger_sister();
00068 sdyn3 * b3 = b2->get_younger_sister();
00069
00070 b1->set_label(1);
00071 b2->set_label(2);
00072 b3->set_label(3);
00073
00074 b->set_mass(1 + m3);
00075 b1->set_mass(1 - m2);
00076 b2->set_mass(m2);
00077 b3->set_mass(m3);
00078
00079 kepler_pair_to_triple(k1, k3, b1, b2, b3);
00080
00081 return b;
00082 }
00083
00084
00085
00086 void sdyn3_to_system(sdyn3 * root, body * system)
00087 {
00088 int n = 0;
00089 for_all_daughters(sdyn3, root, bb) {
00090 system[n].index = bb->get_index();
00091 system[n].mass = bb->get_mass();
00092 for (int kp = 0; kp < 3; kp++) system[n].pos[kp] = bb->get_pos()[kp];
00093 for (int kv = 0; kv < 3; kv++) system[n].vel[kv] = bb->get_vel()[kv];
00094 n++;
00095 }
00096 }