1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::rc::Rc;
use std::cell::RefCell;
use na;
use ncollide::math::Scalar;
use object::RigidBody;
use math::Point;
pub struct Anchor<N: Scalar, P> {
pub body: Option<Rc<RefCell<RigidBody<N>>>>,
pub position: P
}
impl<N: Scalar, P> Anchor<N, P> {
pub fn new(body: Option<Rc<RefCell<RigidBody<N>>>>, position: P) -> Anchor<N, P> {
Anchor {
body: body,
position: position
}
}
}
impl<N: Scalar, P> Anchor<N, P> {
pub fn center_of_mass(&self) -> Point<N> {
match self.body {
Some(ref b) => {
let rb = b.borrow();
rb.center_of_mass().clone()
},
None => na::origin()
}
}
}