Function parse_vector3

Source
pub fn parse_vector3(
    value: &Value,
    key: &str,
) -> Result<Vector3<f32>, SimulationError>
Expand description

Helper function to parse Vector3 from YAML

§Arguments

  • value - YAML value
  • key - key to parse

§Returns

  • Vector3<f32> - parsed vector

§Errors

  • SimulationError - if the value is not a valid vector

§Example

use nalgebra::Vector3;
use peng_quad::{parse_vector3, SimulationError};
let value = serde_yaml::from_str("test: [1.0, 2.0, 3.0]").unwrap();
assert_eq!(parse_vector3(&value, "test").unwrap(), Vector3::new(1.0, 2.0, 3.0));