Add conversion of Rotation and UnitComplex from/to glam types.
This commit is contained in:
parent
729a8fd7f2
commit
bdf0de68cf
|
@ -23,8 +23,6 @@ mod rotation_simba; // TODO: implement Rotation methods.
|
||||||
mod rotation_specialization;
|
mod rotation_specialization;
|
||||||
|
|
||||||
mod quaternion;
|
mod quaternion;
|
||||||
#[cfg(feature = "alga")]
|
|
||||||
mod quaternion_alga;
|
|
||||||
mod quaternion_construction;
|
mod quaternion_construction;
|
||||||
mod quaternion_conversion;
|
mod quaternion_conversion;
|
||||||
mod quaternion_coordinates;
|
mod quaternion_coordinates;
|
||||||
|
@ -32,8 +30,6 @@ mod quaternion_ops;
|
||||||
mod quaternion_simba;
|
mod quaternion_simba;
|
||||||
|
|
||||||
mod dual_quaternion;
|
mod dual_quaternion;
|
||||||
#[cfg(feature = "alga")]
|
|
||||||
mod dual_quaternion_alga;
|
|
||||||
mod dual_quaternion_construction;
|
mod dual_quaternion_construction;
|
||||||
mod dual_quaternion_conversion;
|
mod dual_quaternion_conversion;
|
||||||
mod dual_quaternion_ops;
|
mod dual_quaternion_ops;
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
use crate::{Rotation2, Rotation3, UnitQuaternion};
|
||||||
|
use glam::{DMat2, DQuat, Mat2, Quat};
|
||||||
|
|
||||||
|
impl From<Rotation2<f32>> for Mat2 {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: Rotation2<f32>) -> Mat2 {
|
||||||
|
e.into_inner().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Rotation2<f64>> for DMat2 {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: Rotation2<f64>) -> DMat2 {
|
||||||
|
e.into_inner().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Rotation3<f32>> for Quat {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: Rotation3<f32>) -> Quat {
|
||||||
|
UnitQuaternion::from(e).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Rotation3<f64>> for DQuat {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: Rotation3<f64>) -> DQuat {
|
||||||
|
UnitQuaternion::from(e).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "convert-glam-unchecked")]
|
||||||
|
mod unchecked {
|
||||||
|
use crate::{Rotation2, Rotation3, UnitQuaternion};
|
||||||
|
use glam::{DMat2, DQuat, Mat2, Quat};
|
||||||
|
|
||||||
|
impl From<Mat2> for Rotation2<f32> {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: Mat2) -> Rotation2<f32> {
|
||||||
|
Rotation2::from_matrix_unchecked(e.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<DMat2> for Rotation2<f64> {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: DMat2) -> Rotation2<f64> {
|
||||||
|
Rotation2::from_matrix_unchecked(e.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Quat> for Rotation3<f32> {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: Quat) -> Rotation3<f32> {
|
||||||
|
Rotation3::from(UnitQuaternion::from(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<DQuat> for Rotation3<f64> {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: DQuat) -> Rotation3<f64> {
|
||||||
|
Rotation3::from(UnitQuaternion::from(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
use crate::UnitComplex;
|
||||||
|
use glam::{DMat2, Mat2};
|
||||||
|
|
||||||
|
impl From<UnitComplex<f32>> for Mat2 {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: UnitComplex<f32>) -> Mat2 {
|
||||||
|
e.to_rotation_matrix().into_inner().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<UnitComplex<f64>> for DMat2 {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: UnitComplex<f64>) -> DMat2 {
|
||||||
|
e.to_rotation_matrix().into_inner().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "convert-glam-unchecked")]
|
||||||
|
mod unchecked {
|
||||||
|
use crate::{Rotation2, UnitComplex};
|
||||||
|
use glam::{DMat2, Mat2};
|
||||||
|
|
||||||
|
impl From<Mat2> for UnitComplex<f32> {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: Mat2) -> UnitComplex<f32> {
|
||||||
|
Rotation2::from_matrix_unchecked(e.into()).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<DMat2> for UnitComplex<f64> {
|
||||||
|
#[inline]
|
||||||
|
fn from(e: DMat2) -> UnitComplex<f64> {
|
||||||
|
Rotation2::from_matrix_unchecked(e.into()).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,3 +2,5 @@ mod glam_isometry;
|
||||||
mod glam_matrix;
|
mod glam_matrix;
|
||||||
mod glam_point;
|
mod glam_point;
|
||||||
mod glam_quaternion;
|
mod glam_quaternion;
|
||||||
|
mod glam_rotation;
|
||||||
|
mod glam_unit_complex;
|
||||||
|
|
Loading…
Reference in New Issue