Remove ToComponents and CompositeTransform traits

Fixes #274

# Conflicts:
#	src/transform.rs
This commit is contained in:
Brendan Zabarauskas 2015-12-13 02:20:53 +11:00
parent 21a73e278d
commit 75b6548179
2 changed files with 0 additions and 49 deletions

View file

@ -211,39 +211,3 @@ impl<S: BaseNum> From<AffineMatrix3<S>> for Matrix4<S> {
} }
impl<S: BaseFloat> Transform3<S> for AffineMatrix3<S> {} impl<S: BaseFloat> Transform3<S> for AffineMatrix3<S> {}
/// A trait that allows extracting components (rotation, translation, scale)
/// from an arbitrary transformations
pub trait ToComponents<P: Point, R: Rotation<P>> where
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
<P as Point>::Scalar: BaseFloat,
{
/// Extract the (scale, rotation, translation) triple
fn decompose(&self) -> (P::Vector, R, P::Vector);
}
pub trait ToComponents2<S: BaseFloat, R: Rotation2<S>>: ToComponents<Point2<S>, R> {}
pub trait ToComponents3<S: BaseFloat, R: Rotation3<S>>: ToComponents<Point3<S>, R> {}
pub trait CompositeTransform<P: Point, R: Rotation<P>>: Transform<P> + ToComponents<P, R> where
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
<P as Point>::Scalar: BaseFloat,
{}
pub trait CompositeTransform2<S: BaseFloat, R: Rotation2<S>>: Transform2<S> + ToComponents2<S, R> {}
pub trait CompositeTransform3<S: BaseFloat, R: Rotation3<S>>: Transform3<S> + ToComponents3<S, R> {}
impl<P: Point, R: Rotation<P> + Clone> ToComponents<P, R> for Decomposed<P::Vector, R> where
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
<P as Point>::Scalar: BaseFloat,
{
fn decompose(&self) -> (P::Vector, R, P::Vector) {
(P::Vector::one().mul_s(self.scale), self.rot.clone(), self.disp.clone())
}
}
impl<S: BaseFloat, R: Rotation2<S> + Clone> ToComponents2<S, R> for Decomposed<Vector2<S>, R> {}
impl<S: BaseFloat, R: Rotation3<S> + Clone> ToComponents3<S, R> for Decomposed<Vector3<S>, R> {}
impl<S: BaseFloat, R: Rotation2<S> + Clone> CompositeTransform2<S, R> for Decomposed<Vector2<S>, R> {}
impl<S: BaseFloat, R: Rotation3<S> + Clone> CompositeTransform3<S, R> for Decomposed<Vector3<S>, R> {}

View file

@ -41,16 +41,3 @@ fn test_look_at() {
let view_point = Point3::new(0.0f64, 1.0, 5.0); let view_point = Point3::new(0.0f64, 1.0, 5.0);
assert!(t.transform_point(point).approx_eq(&view_point)); assert!(t.transform_point(point).approx_eq(&view_point));
} }
#[test]
fn test_components() {
let t = Decomposed {
scale: 1.5f64,
rot: Quaternion::new(0.5f64,0.5,0.5,0.5),
disp: Vector3::new(6.0f64,-7.0,8.0)
};
let (scale, rot, disp) = t.decompose();
assert_eq!(scale, Vector3::from_value(t.scale));
assert_eq!(rot, t.rot);
assert_eq!(disp, t.disp);
}