1extern crate cgmath;
2extern crate collision;
3
4use cgmath::{BaseFloat, Decomposed, EuclideanSpace, One, Rotation, Transform};
5pub use collision::{Interpolate, TranslationInterpolate};
6
7pub trait Pose<P, R>: Transform<P>
9where
10 P: EuclideanSpace,
11{
12 fn new(position: P, rotation: R) -> Self;
14 fn set_rotation(&mut self, rotation: R);
16 fn set_position(&mut self, position: P);
18 fn rotation(&self) -> R;
20 fn position(&self) -> P;
22}
23
24pub trait PhysicsTime<S> {
25 fn delta_seconds(&self) -> S;
26}
27
28impl<P, R> Pose<P, R> for Decomposed<P::Diff, R>
29where
30 P: EuclideanSpace,
31 P::Scalar: BaseFloat,
32 R: Rotation<P>,
33{
34 fn new(position: P, rotation: R) -> Self {
35 Decomposed {
36 rot: rotation,
37 disp: position.to_vec(),
38 scale: P::Scalar::one(),
39 }
40 }
41
42 fn set_rotation(&mut self, rotation: R) {
43 self.rot = rotation;
44 }
45
46 fn set_position(&mut self, position: P) {
47 self.disp = position.to_vec();
48 }
49
50 fn rotation(&self) -> R {
51 self.rot
52 }
53
54 fn position(&self) -> P {
55 P::from_vec(self.disp)
56 }
57}