-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
math.rs
35 lines (29 loc) · 941 Bytes
/
math.rs
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
pub type Point<const D: usize> = nalgebra::Point<f64, D>;
pub type Vector<const D: usize> = nalgebra::SVector<f64, D>;
/// A transform
pub struct Transform(parry3d_f64::math::Isometry<f64>);
impl Transform {
/// Transform the given point
pub fn transform_point(&self, point: &Point<3>) -> Point<3> {
self.0.transform_point(point)
}
/// Transform the given vector
pub fn transform_vector(&self, vector: &Vector<3>) -> Vector<3> {
self.0.transform_vector(vector)
}
}
impl From<parry3d_f64::math::Isometry<f64>> for Transform {
fn from(isometry: parry3d_f64::math::Isometry<f64>) -> Self {
Self(isometry)
}
}
impl From<Transform> for parry3d_f64::math::Isometry<f64> {
fn from(transform: Transform) -> Self {
transform.0
}
}
impl<'r> From<&'r Transform> for parry3d_f64::math::Isometry<f64> {
fn from(transform: &Transform) -> Self {
transform.0
}
}