Merge pull request #275 from bjz/remove-to-components

Remove ToComponents and CompositeTransform traits
This commit is contained in:
Brendan Zabarauskas 2015-12-13 11:57:39 +11:00
commit 4c62ef4efb
3 changed files with 5 additions and 49 deletions

View file

@ -12,6 +12,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Removed
- Remove redundant `Point::{min, max}` methods - these are now covered by the
`Array::{min, max}` methods that were introduced in 0.5.0.
- Removed `ToComponents`, `ToComponents2`, and `ToComponents3`. If you were
relying on `ToComponents::decompose`, you can produce the same effect by
accessing the fields on `Decomposed` directly. To create the scale vector,
use: `Vector::from_value(transform.scale)`.
- Removed `CompositeTransform`, `CompositeTransform2`, and `CompositeTransform3`.
## [v0.6.0] - 2015-12-12

View file

@ -211,39 +211,3 @@ impl<S: BaseNum> From<AffineMatrix3<S>> for Matrix4<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);
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);
}