From dacb511b781faf52a6c3588d5ea657b002e418fb Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sat, 23 Apr 2016 17:08:40 +1000 Subject: [PATCH] Add Euler::new function --- src/euler.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/euler.rs b/src/euler.rs index 8b29421..32a66aa 100644 --- a/src/euler.rs +++ b/src/euler.rs @@ -66,14 +66,27 @@ use num::BaseFloat; #[derive(PartialEq, Eq)] #[derive(RustcEncodable, RustcDecodable)] pub struct Euler { - /// The angle to apply around the _x_ axis. Also known at the _pitch_ angle. + /// The angle to apply around the _x_ axis. Also known at the _pitch_. pub x: A, - /// The angle to apply around the _y_ axis. Also known at the _yaw_ angle. + /// The angle to apply around the _y_ axis. Also known at the _yaw_. pub y: A, - /// The angle to apply around the _z_ axis. Also known at the _roll_ angle. + /// The angle to apply around the _z_ axis. Also known at the _roll_. pub z: A, } +impl Euler { + /// Construct a set of euler angles. + /// + /// # Arguments + /// + /// * `x` - The angle to apply around the _x_ axis. Also known at the _pitch_. + /// * `y` - The angle to apply around the _y_ axis. Also known at the _yaw_. + /// * `z` - The angle to apply around the _z_ axis. Also known at the _roll_. + pub fn new(x: A, y: A, z: A) -> Euler { + Euler { x: x, y: y, z: z } + } +} + impl From> for Euler> { fn from(src: Quaternion) -> Euler> { let sig: S = cast(0.499).unwrap();