In Python, Brahe uses array-like types (lists, tuples, numpy arrays, etc.) as inputs for vector quantities (e.g. position, velocity, etc.) and returns numpy arrays as outputs for vector quantities. In Rust, Brahe uses nalgebra arrays for both inputs and outputs of vector quantities.
importbraheasbhimportnumpyasnp# Brahe inputs can be python listslist_input=[-122.41,37.77,16.0]ecef_list=bh.position_geodetic_to_ecef(list_input,bh.AngleFormat.DEGREES)# It can also be numpy arraysarray_input=np.array([-122.41,37.77,16.0])ecef_array=bh.position_geodetic_to_ecef(array_input,bh.AngleFormat.DEGREES)# Any array-like (python set, tuple, etc.) will work as welltuple_input=(-122.41,37.77,16.0)ecef_tuple=bh.position_geodetic_to_ecef(tuple_input,bh.AngleFormat.DEGREES)print(f'ECEF from list: {ecef_list}')print(f'ECEF from array: {ecef_array}')print(f'ECEF from tuple: {ecef_tuple}')# The output of Brahe functions that return vectors is always a numpy arrayprint(f'Type of ECEF output: {type(ecef_list)}')print(f'Type of ECEF output: {type(ecef_array)}')
#[allow(unused_imports)]usebraheasbh;usenalgebraasna;fnmain(){// In rust inputs must be nalgebra arraysletarray_input=na::Vector3::new(-122.41,37.77,16.0);letecef_array=bh::position_geodetic_to_ecef(array_input,bh::AngleFormat::Degrees);// println!("ECEF from vec: {:?}", ecef_vec);println!("ECEF from array: {:?}",ecef_array);// The output of Brahe functions that return vectors is always a nalgebra arrayprintln!("Type of ECEF output: {}",std::any::type_name_of_val(&ecef_array));}
ECEF from list: [-2705661.06457674 -4261795.32689662 3885305.39466925]
ECEF from array: [-2705661.06457674 -4261795.32689662 3885305.39466925]
ECEF from tuple: [-2705661.06457674 -4261795.32689662 3885305.39466925]
Type of ECEF output: <class 'numpy.ndarray'>
Type of ECEF output: <class 'numpy.ndarray'>
Brahe uses SI base units (meters, seconds, kilograms, etc.) for all inputs and outputs of physical quantities unless otherwise specified. This is to remove any ambiguity about the units of inputs and outputs, and to make it easier to work with the library and chain together different functions without needing to worry about unit conversions.
It is the responsibility of the user to ensure that the inputs to Brahe functions are in the correct units, and to convert the outputs of Brahe functions to the desired units if needed.
For functions that deal with angular quantities for either inputs or outputs, Brahe provides the AngleFormat enum to specify the format of the angles. Given the frequency of working with different angle formats this makes it easy to work with different formats without needing to manually convert before or after calling Brahe functions.