ClarkeRubber

Incomplete - Gravity to create motion

Nov 25th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. function movePoint($current_point, $other_points, $mass, $time_interval){
  2.     //Given the above information, this function will return the resulting point after it has been affected by the gravity of the other points.
  3.     /* Basically the method is:
  4.         -Find the distance between the given point, and another of the rest of the points
  5.         -Find the net force experienced by the point
  6.         -Separate net force into the X, Y and Z planes.
  7.         -Repeat steps 1-3, summing up the separated forces.
  8.         -Then, a = G*((m1*m2)/(r^2))/m1
  9.         -I guess that the period is going to affect the velocity, and then displacement... how does it go again. :S
  10.         -s = ut+1/2at^2
  11.         -...I'm going to need more information from the $current_point, I believe. Going to need velocity aswell.
  12.         -shit...
  13.     */
  14.     $net['x'] = 0;
  15.     $net['y'] = 0;
  16.     $net['z'] = 0;
  17.    
  18.     $dif['x'] = 0;
  19.     $dif['y'] = 0;
  20.     $dif['z'] = 0;
  21.     foreach($other_points as $other){
  22.         //I suck at creating variable names
  23.         //And I didn't really think this through
  24.         if($current_point['x'] != $other['x'] && $current_point['y'] != $other['y'] && $current_point['z'] != $other['x']){
  25.             $dif['x'] = $current_point['x']-$other['x'];
  26.             $dif['y'] = $current_point['y']-$other['y'];
  27.             $dif['z'] = $current_point['z']-$other['z'];
  28.             $distance = sqrt(pow($dif['x'], 2)+pow($dif['y'], 2)+pow($dif['z'], 2)); //Pretty much the radius
  29.             $acceleration = ((6.67300*pow(10, -11)*pow($mass, 2))/pow($distance, 2))/$mass; //I guess that's right
  30.             //now to divide this into the 3 planes - x, y and z
  31.             //Fuck... I'll come back to this tomorrow... Needs more trig.
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment