// Returns the x rotation and the z rotation
// Refer to: http://www.fundza.com/mel/axis_to_vector/index.html
// Malcolm Kesson
global proc float[] aimY(vector $vec) {
    float $out[2];
    float $xAngle, $zAngle, $xyLength, $vecLength;
      
    $xyLength = sqrt(($vec.x) * ($vec.x) +
                      ($vec.y) * ($vec.y));
    $vecLength = sqrt(($vec.x) * ($vec.x) +
                       ($vec.y) * ($vec.y) + 
                       ($vec.z) * ($vec.z));
      
    // $xyLength will be zero when $vec is pointing
    // along the +z or -z axis
    if($xyLength == 0)
        $zAngle = ($vec.x) > 0 ? deg_to_rad(90) : deg_to_rad(-90);
    else
        $zAngle = acos(($vec.y)/$xyLength);
      
    $xAngle = acos($xyLength/$vecLength);
      
    $xAngle = ($vec.z) > 0 ? $xAngle : -$xAngle;
    $out[0] = rad_to_deg($xAngle);
      
    $zAngle = ($vec.x) > 0 ? -$zAngle : $zAngle;
    $out[1] = rad_to_deg($zAngle);
    return $out;
    }