1
$\begingroup$

Is my code correct to get six Keplerian parameters?

function calculateKeplerianParameters($angle, $speed, $mu)
{
   
   $radius = ($mu / pow($speed, 2)) * (1 / (1 + $speed * $speed / $mu * pow(cos($angle), 2)));

  
   $radialSpeed = sqrt($mu / $radius) * cos($angle);

 
   $angularSpeed = $mu / pow($radius, 2);

  
   $angularMomentum = $radius * $radialSpeed;

  
   $inclination = acos($angularMomentum / sqrt($mu * $radius));


   $altitude = $radius - $mu / $speed;



   return array(
       'Radius' => $radius,
    'RadialSpeed' => $radialSpeed,
       'AngularSpeed' => $angularSpeed,
    'AngularMomentum' => $angularMomentum,
       'Inclination' => $inclination,
    'Altitude' => $altitude
   );
}


$angle = deg2rad(45);
$speed = 1000; 
$mu = 398600; 


$keplerianParameters = calculateKeplerianParameters($angle, $speed, $mu);


print_r($keplerianParameters);
$\endgroup$
4
  • 2
    $\begingroup$ These aren't the typical six keplerian parameters, and with all your values seeming to be scalar quantities, I don't think you have enough info to determine orbital inclination. $\endgroup$
    – notovny
    Commented Feb 5 at 19:48
  • 1
    $\begingroup$ I agree with notovny. At the very least it looks like you've misunderstood angular momentum and inclination. I haven't thoroughly checked the rest, but it'd make sense to be explicit about your units as well. $\endgroup$
    – Erin Anne
    Commented Feb 5 at 20:33
  • 1
    $\begingroup$ Like Notovny said, not the usual Keplerian elements (semi-major, eccentricity, inclination, RAAN arg of perigee, true anomaly). In addition to units, you need to tell us the meaning of your values. For instance, I'm trying to figure out the meaning of radial speed, and how it could vary from 0 to X with the cos(angle). $\endgroup$
    – Carlos N
    Commented Feb 6 at 0:57
  • 1
    $\begingroup$ Orbital elements have six degrees of freedom, just as do 3D position & velocity. As you are only providing three scalar values to your function calculateKeplerianParameters, there is something seriously wrong here. There are in fact multiple things that are seriously wrong. $\endgroup$ Commented Feb 6 at 2:13

0

Browse other questions tagged or ask your own question.