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 crate::prelude::*;
use std::error::Error;
use std::fmt::{self, Debug};
#[cfg(any(test, feature = "use-mocks"))]
use mockiato::mockable;
mod rotation_translator_impl;
pub use self::rotation_translator_impl::*;
#[cfg_attr(any(test, feature = "use-mocks"), mockable)]
pub trait NphysicsRotationTranslator: Debug {
fn to_nphysics_rotation(&self, orientation: Radians) -> f64;
fn to_radians(
&self,
nphysics_rotation: f64,
) -> Result<Radians, NphysicsRotationTranslatorError>;
}
#[derive(Debug, Clone, PartialEq)]
pub enum NphysicsRotationTranslatorError {
InvalidNphysicsValue(f64),
}
impl fmt::Display for NphysicsRotationTranslatorError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Given nphysics value is not in the range (-pi; pi]")
}
}
impl Error for NphysicsRotationTranslatorError {}