diff --git a/src/angle.rs b/src/angle.rs index 7cb6066..ed1b78a 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -76,11 +76,15 @@ pub impl Degrees: Ord { * An angular rotation around an arbitary axis */ pub struct Rotation { - axis: Vec3, theta: Radians, + axis: Vec3, } pub impl Rotation { + static pure fn new(theta: Radians, axis: Vec3) -> Rotation { + Rotation { theta: move theta, axis: move axis } + } + pure fn to_mat3() -> Mat3 { let c: T = cos(&self.theta); let s: T = sin(&self.theta); diff --git a/src/test/test_angle.rs b/src/test/test_angle.rs index ca9461b..14c5c63 100644 --- a/src/test/test_angle.rs +++ b/src/test/test_angle.rs @@ -55,8 +55,8 @@ fn test_rotation() { { let pos = Vec4::new(1.0, 0.0, 0.0, 1.0); // the position to transform let rot = Rotation { - axis: Vec3::new(0.0, 0.0, 1.0), // unit_z theta: Degrees(180.0).to_radians(), + axis: Vec3::new(0.0, 0.0, 1.0), // unit_z }; let newpos = rot.to_mat4().mul_v(&pos); @@ -68,13 +68,13 @@ fn test_rotation() { let pos = Vec4::new(4f32, 0f32, 0f32, 1f32); let rot_a = Rotation { - axis: Vec3::new(0f32, 1f32, 0f32), // unit_y theta: Degrees(90f32).to_radians(), + axis: Vec3::new(0f32, 1f32, 0f32), // unit_y }; let rot_b = Rotation { - axis: -Vec3::new(0f32, 1f32, 0f32), // -unit_y theta: Degrees(90f32).to_radians(), + axis: -Vec3::new(0f32, 1f32, 0f32), // -unit_y }; let newpos_a = rot_a.to_mat4().mul_v(&pos); @@ -86,4 +86,6 @@ fn test_rotation() { assert newpos_a == expected_pos_a; assert newpos_b == expected_pos_b; } + + // TODO: test to_quat } \ No newline at end of file