Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

scat_init.C

Go to the documentation of this file.
00001 
00002        //=======================================================//    _\|/_
00003       //  __  _____           ___                    ___       //      /|\
00004      //  /      |      ^     |   \  |         ^     |   \     //          _\|/_
00005     //   \__    |     / \    |___/  |        / \    |___/    //            /|\
00006    //       \   |    /___\   |  \   |       /___\   |   \   // _\|/_
00007   //     ___/   |   /     \  |   \  |____  /     \  |___/  //   /|\     
00008  //                                                       //            _\|/_
00009 //=======================================================//              /|\
00010 
00011 #include "scatter3.h"
00012 
00013 // set_orientation:  Set up the orientation of the outer orbit with
00014 //                   respect to the inner binary [which always lies in
00015 //                   the (x-y) plane].   See "sigma3.h" for details.
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     // Construct the normal vector:
00023 
00024     vector n = vector(sin_theta*cos(p.phi), sin_theta*sin(p.phi), mu);
00025 
00026     // Construct unit vectors a and b perpendicular to n:
00027 
00028     vector temp = vector(1, 0, 0);
00029     if (abs(n[0]) > .5) temp = vector(0, 1, 0); // temp is not parallel to n
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;       // Force (a, b) to be (x, y) for n = +/-z
00036     
00037     // Construct *random* unit vectors l and t perpendicular to each
00038     // other and to n (psi = 0 ==> periastron along a):
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 // set_up_dynamics:  Turn the system described by two kepler structures
00048 //                   into an sdyn3 tree; return a pointer to the root
00049 //                   node of the tree.
00050 
00051 sdyn3 * set_up_dynamics(real m2,      // mass of secondary in binary
00052                         real m3,      // mass of projectile (m1 + m2 = 1)
00053                         kepler & k1,  // inner binary
00054                         kepler & k3)  // outer binary
00055 {
00056     // Create bodies for integration.
00057 
00058     sdyn3 * b = mksdyn3(3);                 // pointer to the 3-body system
00059 
00060     // Initialize the dynamics.
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 // sdyn3_to_system:  Save sdyn3 dynamical information in the specified array.
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 }

Generated at Sun Feb 24 09:57:14 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001