diff --git a/src/cgmath/rotation.rs b/src/cgmath/rotation.rs index 699a43b..28dc015 100644 --- a/src/cgmath/rotation.rs +++ b/src/cgmath/rotation.rs @@ -30,7 +30,7 @@ pub trait Rotation2 : Eq + ApproxEq + ToMat2 -+ ToRot2 ++ ToBasis2 { fn rotate_point2(&self, point: &Point2) -> Point2; fn rotate_vec2(&self, vec: &Vec2) -> Vec2; @@ -49,7 +49,7 @@ pub trait Rotation3 : Eq + ApproxEq + ToMat3 -+ ToRot3 ++ ToBasis3 + ToQuat { fn rotate_point3(&self, point: &Point3) -> Point3; @@ -68,30 +68,30 @@ pub trait Rotation3 /// enforce orthogonality at the type level the operations have been restricted /// to a subeset of those implemented on `Mat2`. #[deriving(Eq, Clone)] -pub struct Rot2 { +pub struct Basis2 { priv mat: Mat2 } -impl Rot2 { +impl Basis2 { #[inline] pub fn as_mat2<'a>(&'a self) -> &'a Mat2 { &'a self.mat } } -pub trait ToRot2 { - fn to_rot2(&self) -> Rot2; +pub trait ToBasis2 { + fn to_rot2(&self) -> Basis2; } -impl ToRot2 for Rot2 { +impl ToBasis2 for Basis2 { #[inline] - fn to_rot2(&self) -> Rot2 { self.clone() } + fn to_rot2(&self) -> Basis2 { self.clone() } } -impl ToMat2 for Rot2 { +impl ToMat2 for Basis2 { #[inline] fn to_mat2(&self) -> Mat2 { self.mat.clone() } } -impl Rotation2 for Rot2 { +impl Rotation2 for Basis2 { #[inline] fn rotate_point2(&self, _point: &Point2) -> Point2 { fail!("Not yet implemented") } @@ -102,15 +102,15 @@ impl Rotation2 for Rot2 { fn rotate_ray2(&self, _ray: &Ray2) -> Ray2 { fail!("Not yet implemented") } #[inline] - fn concat(&self, other: &Rot2) -> Rot2 { Rot2 { mat: self.mat.mul_m(&other.mat) } } + fn concat(&self, other: &Basis2) -> Basis2 { Basis2 { mat: self.mat.mul_m(&other.mat) } } #[inline] - fn concat_self(&mut self, other: &Rot2) { self.mat.mul_self_m(&other.mat); } + fn concat_self(&mut self, other: &Basis2) { self.mat.mul_self_m(&other.mat); } // TODO: we know the matrix is orthogonal, so this could be re-written // to be faster #[inline] - fn invert(&self) -> Rot2 { Rot2 { mat: self.mat.invert().unwrap() } } + fn invert(&self) -> Basis2 { Basis2 { mat: self.mat.invert().unwrap() } } // TODO: we know the matrix is orthogonal, so this could be re-written // to be faster @@ -118,7 +118,7 @@ impl Rotation2 for Rot2 { fn invert_self(&mut self) { self.mat.invert_self(); } } -impl ApproxEq for Rot2 { +impl ApproxEq for Basis2 { #[inline] fn approx_epsilon() -> S { // TODO: fix this after static methods are fixed in rustc @@ -126,12 +126,12 @@ impl ApproxEq for Rot2 { } #[inline] - fn approx_eq(&self, other: &Rot2) -> bool { + fn approx_eq(&self, other: &Basis2) -> bool { self.mat.approx_eq(&other.mat) } #[inline] - fn approx_eq_eps(&self, other: &Rot2, approx_epsilon: &S) -> bool { + fn approx_eq_eps(&self, other: &Basis2, approx_epsilon: &S) -> bool { self.mat.approx_eq_eps(&other.mat, approx_epsilon) } } @@ -143,29 +143,29 @@ impl ApproxEq for Rot2 { /// `math::Mat3`. To ensure orthogonality is maintained, the operations have /// been restricted to a subeset of those implemented on `Mat3`. #[deriving(Eq, Clone)] -pub struct Rot3 { +pub struct Basis3 { priv mat: Mat3 } -impl Rot3 { +impl Basis3 { #[inline] - pub fn look_at(dir: &Vec3, up: &Vec3) -> Rot3 { - Rot3 { mat: Mat3::look_at(dir, up) } + pub fn look_at(dir: &Vec3, up: &Vec3) -> Basis3 { + Basis3 { mat: Mat3::look_at(dir, up) } } /// Create a rotation matrix from a rotation around the `x` axis (pitch). - pub fn from_angle_x(theta: Rad) -> Rot3 { - Rot3 { mat: Mat3::from_angle_x(theta) } + pub fn from_angle_x(theta: Rad) -> Basis3 { + Basis3 { mat: Mat3::from_angle_x(theta) } } /// Create a rotation matrix from a rotation around the `y` axis (yaw). - pub fn from_angle_y(theta: Rad) -> Rot3 { - Rot3 { mat: Mat3::from_angle_y(theta) } + pub fn from_angle_y(theta: Rad) -> Basis3 { + Basis3 { mat: Mat3::from_angle_y(theta) } } /// Create a rotation matrix from a rotation around the `z` axis (roll). - pub fn from_angle_z(theta: Rad) -> Rot3 { - Rot3 { mat: Mat3::from_angle_z(theta) } + pub fn from_angle_z(theta: Rad) -> Basis3 { + Basis3 { mat: Mat3::from_angle_z(theta) } } /// Create a rotation matrix from a set of euler angles. @@ -175,39 +175,39 @@ impl Rot3 { /// - `x`: the angular rotation around the `x` axis (pitch). /// - `y`: the angular rotation around the `y` axis (yaw). /// - `z`: the angular rotation around the `z` axis (roll). - pub fn from_euler(x: Rad, y: Rad, z: Rad) -> Rot3 { - Rot3 { mat: Mat3::from_euler(x, y ,z) } + pub fn from_euler(x: Rad, y: Rad, z: Rad) -> Basis3 { + Basis3 { mat: Mat3::from_euler(x, y ,z) } } /// Create a rotation matrix from a rotation around an arbitrary axis. - pub fn from_axis_angle(axis: &Vec3, angle: Rad) -> Rot3 { - Rot3 { mat: Mat3::from_axis_angle(axis, angle) } + pub fn from_axis_angle(axis: &Vec3, angle: Rad) -> Basis3 { + Basis3 { mat: Mat3::from_axis_angle(axis, angle) } } #[inline] pub fn as_mat3<'a>(&'a self) -> &'a Mat3 { &'a self.mat } } -pub trait ToRot3 { - fn to_rot3(&self) -> Rot3; +pub trait ToBasis3 { + fn to_rot3(&self) -> Basis3; } -impl ToRot3 for Rot3 { +impl ToBasis3 for Basis3 { #[inline] - fn to_rot3(&self) -> Rot3 { self.clone() } + fn to_rot3(&self) -> Basis3 { self.clone() } } -impl ToMat3 for Rot3 { +impl ToMat3 for Basis3 { #[inline] fn to_mat3(&self) -> Mat3 { self.mat.clone() } } -impl ToQuat for Rot3 { +impl ToQuat for Basis3 { #[inline] fn to_quat(&self) -> Quat { self.mat.to_quat() } } -impl Rotation3 for Rot3 { +impl Rotation3 for Basis3 { #[inline] fn rotate_point3(&self, _point: &Point3) -> Point3 { fail!("Not yet implemented") } @@ -218,15 +218,15 @@ impl Rotation3 for Rot3 { fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented") } #[inline] - fn concat(&self, other: &Rot3) -> Rot3 { Rot3 { mat: self.mat.mul_m(&other.mat) } } + fn concat(&self, other: &Basis3) -> Basis3 { Basis3 { mat: self.mat.mul_m(&other.mat) } } #[inline] - fn concat_self(&mut self, other: &Rot3) { self.mat.mul_self_m(&other.mat); } + fn concat_self(&mut self, other: &Basis3) { self.mat.mul_self_m(&other.mat); } // TODO: we know the matrix is orthogonal, so this could be re-written // to be faster #[inline] - fn invert(&self) -> Rot3 { Rot3 { mat: self.mat.invert().unwrap() } } + fn invert(&self) -> Basis3 { Basis3 { mat: self.mat.invert().unwrap() } } // TODO: we know the matrix is orthogonal, so this could be re-written // to be faster @@ -234,7 +234,7 @@ impl Rotation3 for Rot3 { fn invert_self(&mut self) { self.mat.invert_self(); } } -impl ApproxEq for Rot3 { +impl ApproxEq for Basis3 { #[inline] fn approx_epsilon() -> S { // TODO: fix this after static methods are fixed in rustc @@ -242,21 +242,21 @@ impl ApproxEq for Rot3 { } #[inline] - fn approx_eq(&self, other: &Rot3) -> bool { + fn approx_eq(&self, other: &Basis3) -> bool { self.mat.approx_eq(&other.mat) } #[inline] - fn approx_eq_eps(&self, other: &Rot3, approx_epsilon: &S) -> bool { + fn approx_eq_eps(&self, other: &Basis3, approx_epsilon: &S) -> bool { self.mat.approx_eq_eps(&other.mat, approx_epsilon) } } // Quaternion Rotation impls -impl ToRot3 for Quat { +impl ToBasis3 for Quat { #[inline] - fn to_rot3(&self) -> Rot3 { Rot3 { mat: self.to_mat3() } } + fn to_rot3(&self) -> Basis3 { Basis3 { mat: self.to_mat3() } } } impl ToQuat for Quat {