use core::fmt::{Debug, Display};
use nalgebra::Matrix6;
use crate::{Adjoint, Real};
use super::se3;
#[derive(Debug)]
pub struct AdjSE3<T> {
pub(crate) val: Matrix6<T>,
}
impl<T> Display for AdjSE3<T>
where
T: Real + Display,
{
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
core::fmt::Display::fmt(&self.val, f)
}
}
impl<T> AdjSE3<T>
where
T: Real,
{
pub fn new_unchecked(val: &[T]) -> Self {
Self {
val: Matrix6::from_column_slice(val),
}
}
pub fn transpose(&self) -> Self {
Self {
val: self.val.transpose(),
}
}
}
impl<T> Adjoint for AdjSE3<T>
where
T: Real,
{
type Algebra = se3<T>;
fn act(&self, other: &Self::Algebra) -> Self::Algebra {
se3 {
val: self.val * other.val,
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_new() {
let adj = AdjSE3 {
val: Matrix6::<f64>::identity(),
};
assert_eq!(adj.val, Matrix6::identity());
}
}