2016-12-05 05:44:42 +08:00
|
|
|
use num::Zero;
|
|
|
|
|
2020-03-21 19:16:46 +08:00
|
|
|
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
2020-03-23 16:16:01 +08:00
|
|
|
use simba::simd::{PrimitiveSimdValue, SimdRealField, SimdValue};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
2017-10-10 01:58:09 +08:00
|
|
|
#[cfg(feature = "mint")]
|
|
|
|
use mint;
|
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::base::dimension::U3;
|
2020-03-22 06:22:55 +08:00
|
|
|
use crate::base::{Matrix3, Matrix4, Scalar, Vector4};
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::geometry::{
|
2020-03-21 19:16:46 +08:00
|
|
|
AbstractRotation, Isometry, Quaternion, Rotation, Rotation3, Similarity, SuperTCategoryOf,
|
|
|
|
TAffine, Transform, Translation, UnitQuaternion,
|
2018-10-13 16:25:34 +08:00
|
|
|
};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This file provides the following conversions:
|
|
|
|
* =============================================
|
|
|
|
*
|
|
|
|
* Quaternion -> Quaternion
|
|
|
|
* UnitQuaternion -> UnitQuaternion
|
2017-08-03 01:37:44 +08:00
|
|
|
* UnitQuaternion -> Rotation<U3>
|
|
|
|
* UnitQuaternion -> Isometry<U3>
|
|
|
|
* UnitQuaternion -> Similarity<U3>
|
|
|
|
* UnitQuaternion -> Transform<U3>
|
2016-12-05 05:44:42 +08:00
|
|
|
* UnitQuaternion -> Matrix<U4> (homogeneous)
|
|
|
|
*
|
2017-07-25 23:49:27 +08:00
|
|
|
* mint::Quaternion <-> Quaternion
|
|
|
|
* UnitQuaternion -> mint::Quaternion
|
|
|
|
*
|
2016-12-05 05:44:42 +08:00
|
|
|
* NOTE:
|
|
|
|
* UnitQuaternion -> Quaternion is already provided by: Unit<T> -> T
|
|
|
|
*/
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2> SubsetOf<Quaternion<N2>> for Quaternion<N1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2020-03-21 19:16:46 +08:00
|
|
|
N1: SimdRealField,
|
|
|
|
N2: SimdRealField + SupersetOf<N1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn to_superset(&self) -> Quaternion<N2> {
|
2018-10-28 14:33:39 +08:00
|
|
|
Quaternion::from(self.coords.to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(q: &Quaternion<N2>) -> bool {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::is_convertible::<_, Vector4<N1>>(&q.coords)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2020-03-21 19:16:46 +08:00
|
|
|
fn from_superset_unchecked(q: &Quaternion<N2>) -> Self {
|
2018-10-28 14:33:39 +08:00
|
|
|
Self {
|
|
|
|
coords: q.coords.to_subset_unchecked(),
|
|
|
|
}
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2> SubsetOf<UnitQuaternion<N2>> for UnitQuaternion<N1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2020-03-21 19:16:46 +08:00
|
|
|
N1: SimdRealField,
|
|
|
|
N2: SimdRealField + SupersetOf<N1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn to_superset(&self) -> UnitQuaternion<N2> {
|
|
|
|
UnitQuaternion::new_unchecked(self.as_ref().to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(uq: &UnitQuaternion<N2>) -> bool {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::is_convertible::<_, Quaternion<N1>>(uq.as_ref())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2020-03-21 19:16:46 +08:00
|
|
|
fn from_superset_unchecked(uq: &UnitQuaternion<N2>) -> Self {
|
2019-03-23 21:29:07 +08:00
|
|
|
Self::new_unchecked(crate::convert_ref_unchecked(uq.as_ref()))
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2> SubsetOf<Rotation<N2, U3>> for UnitQuaternion<N1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2019-03-25 18:21:41 +08:00
|
|
|
N1: RealField,
|
|
|
|
N2: RealField + SupersetOf<N1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2017-08-03 01:37:44 +08:00
|
|
|
#[inline]
|
|
|
|
fn to_superset(&self) -> Rotation3<N2> {
|
|
|
|
let q: UnitQuaternion<N2> = self.to_superset();
|
2016-12-05 05:44:42 +08:00
|
|
|
q.to_rotation_matrix()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(rot: &Rotation3<N2>) -> bool {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::is_convertible::<_, Rotation3<N1>>(rot)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2020-03-21 19:16:46 +08:00
|
|
|
fn from_superset_unchecked(rot: &Rotation3<N2>) -> Self {
|
2017-08-03 01:37:44 +08:00
|
|
|
let q = UnitQuaternion::<N2>::from_rotation_matrix(rot);
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::convert_unchecked(q)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2, R> SubsetOf<Isometry<N2, U3, R>> for UnitQuaternion<N1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2019-03-25 18:21:41 +08:00
|
|
|
N1: RealField,
|
|
|
|
N2: RealField + SupersetOf<N1>,
|
2020-03-21 19:16:46 +08:00
|
|
|
R: AbstractRotation<N2, U3> + SupersetOf<Self>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn to_superset(&self) -> Isometry<N2, U3, R> {
|
2019-03-23 21:29:07 +08:00
|
|
|
Isometry::from_parts(Translation::identity(), crate::convert_ref(self))
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(iso: &Isometry<N2, U3, R>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
iso.translation.vector.is_zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2020-03-21 19:16:46 +08:00
|
|
|
fn from_superset_unchecked(iso: &Isometry<N2, U3, R>) -> Self {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::convert_ref_unchecked(&iso.rotation)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2, R> SubsetOf<Similarity<N2, U3, R>> for UnitQuaternion<N1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2019-03-25 18:21:41 +08:00
|
|
|
N1: RealField,
|
|
|
|
N2: RealField + SupersetOf<N1>,
|
2020-03-21 19:16:46 +08:00
|
|
|
R: AbstractRotation<N2, U3> + SupersetOf<Self>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn to_superset(&self) -> Similarity<N2, U3, R> {
|
2019-03-23 21:29:07 +08:00
|
|
|
Similarity::from_isometry(crate::convert_ref(self), N2::one())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(sim: &Similarity<N2, U3, R>) -> bool {
|
2018-02-02 19:26:35 +08:00
|
|
|
sim.isometry.translation.vector.is_zero() && sim.scaling() == N2::one()
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2020-03-21 19:16:46 +08:00
|
|
|
fn from_superset_unchecked(sim: &Similarity<N2, U3, R>) -> Self {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::convert_ref_unchecked(&sim.isometry)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2, C> SubsetOf<Transform<N2, U3, C>> for UnitQuaternion<N1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2019-03-25 18:21:41 +08:00
|
|
|
N1: RealField,
|
|
|
|
N2: RealField + SupersetOf<N1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
C: SuperTCategoryOf<TAffine>,
|
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn to_superset(&self) -> Transform<N2, U3, C> {
|
|
|
|
Transform::from_matrix_unchecked(self.to_homogeneous().to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(t: &Transform<N2, U3, C>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
<Self as SubsetOf<_>>::is_in_subset(t.matrix())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2020-03-21 19:16:46 +08:00
|
|
|
fn from_superset_unchecked(t: &Transform<N2, U3, C>) -> Self {
|
2016-12-05 05:44:42 +08:00
|
|
|
Self::from_superset_unchecked(t.matrix())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-25 18:21:41 +08:00
|
|
|
impl<N1: RealField, N2: RealField + SupersetOf<N1>> SubsetOf<Matrix4<N2>> for UnitQuaternion<N1> {
|
2017-08-03 01:37:44 +08:00
|
|
|
#[inline]
|
|
|
|
fn to_superset(&self) -> Matrix4<N2> {
|
2016-12-05 05:44:42 +08:00
|
|
|
self.to_homogeneous().to_superset()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(m: &Matrix4<N2>) -> bool {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::is_convertible::<_, Rotation3<N1>>(m)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2020-03-21 19:16:46 +08:00
|
|
|
fn from_superset_unchecked(m: &Matrix4<N2>) -> Self {
|
2019-03-23 21:29:07 +08:00
|
|
|
let rot: Rotation3<N1> = crate::convert_ref_unchecked(m);
|
2016-12-05 05:44:42 +08:00
|
|
|
Self::from_rotation_matrix(&rot)
|
|
|
|
}
|
|
|
|
}
|
2017-07-25 23:49:27 +08:00
|
|
|
|
|
|
|
#[cfg(feature = "mint")]
|
2020-12-18 18:38:33 +08:00
|
|
|
impl<N: Scalar> From<mint::Quaternion<N>> for Quaternion<N> {
|
2017-07-25 23:49:27 +08:00
|
|
|
fn from(q: mint::Quaternion<N>) -> Self {
|
2019-02-17 05:29:41 +08:00
|
|
|
Self::new(q.s, q.v.x, q.v.y, q.v.z)
|
2017-07-25 23:49:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "mint")]
|
2020-12-18 18:38:33 +08:00
|
|
|
impl<N: Scalar> Into<mint::Quaternion<N>> for Quaternion<N> {
|
2017-07-25 23:49:27 +08:00
|
|
|
fn into(self) -> mint::Quaternion<N> {
|
|
|
|
mint::Quaternion {
|
|
|
|
v: mint::Vector3 {
|
|
|
|
x: self[0],
|
|
|
|
y: self[1],
|
|
|
|
z: self[2],
|
|
|
|
},
|
|
|
|
s: self[3],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "mint")]
|
2020-12-18 18:38:33 +08:00
|
|
|
impl<N: Scalar> Into<mint::Quaternion<N>> for UnitQuaternion<N> {
|
2017-07-25 23:49:27 +08:00
|
|
|
fn into(self) -> mint::Quaternion<N> {
|
|
|
|
mint::Quaternion {
|
|
|
|
v: mint::Vector3 {
|
|
|
|
x: self[0],
|
|
|
|
y: self[1],
|
|
|
|
z: self[2],
|
|
|
|
},
|
|
|
|
s: self[3],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-13 16:25:34 +08:00
|
|
|
|
2020-03-22 06:22:55 +08:00
|
|
|
impl<N: SimdRealField> From<UnitQuaternion<N>> for Matrix4<N>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
|
|
|
N::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2018-10-13 16:25:34 +08:00
|
|
|
#[inline]
|
2019-02-17 05:29:41 +08:00
|
|
|
fn from(q: UnitQuaternion<N>) -> Self {
|
2018-10-13 16:25:34 +08:00
|
|
|
q.to_homogeneous()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 06:22:55 +08:00
|
|
|
impl<N: SimdRealField> From<UnitQuaternion<N>> for Rotation3<N>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
|
|
|
N::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2019-02-19 05:41:46 +08:00
|
|
|
#[inline]
|
|
|
|
fn from(q: UnitQuaternion<N>) -> Self {
|
|
|
|
q.to_rotation_matrix()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 06:22:55 +08:00
|
|
|
impl<N: SimdRealField> From<Rotation3<N>> for UnitQuaternion<N>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
|
|
|
N::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2019-02-19 05:41:46 +08:00
|
|
|
#[inline]
|
|
|
|
fn from(q: Rotation3<N>) -> Self {
|
|
|
|
Self::from_rotation_matrix(&q)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-22 06:22:55 +08:00
|
|
|
impl<N: SimdRealField> From<UnitQuaternion<N>> for Matrix3<N>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
|
|
|
N::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2018-10-13 16:25:34 +08:00
|
|
|
#[inline]
|
2019-02-17 05:29:41 +08:00
|
|
|
fn from(q: UnitQuaternion<N>) -> Self {
|
2018-12-10 04:16:06 +08:00
|
|
|
q.to_rotation_matrix().into_inner()
|
2018-10-13 16:25:34 +08:00
|
|
|
}
|
|
|
|
}
|
2018-10-28 14:33:39 +08:00
|
|
|
|
2020-12-18 18:38:33 +08:00
|
|
|
impl<N: Scalar> From<Vector4<N>> for Quaternion<N> {
|
2018-10-28 14:33:39 +08:00
|
|
|
#[inline]
|
|
|
|
fn from(coords: Vector4<N>) -> Self {
|
2019-02-17 05:29:41 +08:00
|
|
|
Self { coords }
|
2018-10-28 14:33:39 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-23 16:16:01 +08:00
|
|
|
|
2020-12-18 18:38:33 +08:00
|
|
|
impl<N: Scalar> From<[N; 4]> for Quaternion<N> {
|
2020-10-25 18:23:51 +08:00
|
|
|
#[inline]
|
|
|
|
fn from(coords: [N; 4]) -> Self {
|
|
|
|
Self {
|
|
|
|
coords: coords.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-23 16:16:01 +08:00
|
|
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 2]> for Quaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as SimdValue>::Element; 2]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [Quaternion<N::Element>; 2]) -> Self {
|
|
|
|
Self::from(Vector4::from([arr[0].coords, arr[1].coords]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 4]> for Quaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as SimdValue>::Element; 4]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [Quaternion<N::Element>; 4]) -> Self {
|
|
|
|
Self::from(Vector4::from([
|
|
|
|
arr[0].coords,
|
|
|
|
arr[1].coords,
|
|
|
|
arr[2].coords,
|
|
|
|
arr[3].coords,
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 8]> for Quaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as SimdValue>::Element; 8]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [Quaternion<N::Element>; 8]) -> Self {
|
|
|
|
Self::from(Vector4::from([
|
|
|
|
arr[0].coords,
|
|
|
|
arr[1].coords,
|
|
|
|
arr[2].coords,
|
|
|
|
arr[3].coords,
|
|
|
|
arr[4].coords,
|
|
|
|
arr[5].coords,
|
|
|
|
arr[6].coords,
|
|
|
|
arr[7].coords,
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 16]> for Quaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as SimdValue>::Element; 16]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [Quaternion<N::Element>; 16]) -> Self {
|
|
|
|
Self::from(Vector4::from([
|
|
|
|
arr[0].coords,
|
|
|
|
arr[1].coords,
|
|
|
|
arr[2].coords,
|
|
|
|
arr[3].coords,
|
|
|
|
arr[4].coords,
|
|
|
|
arr[5].coords,
|
|
|
|
arr[6].coords,
|
|
|
|
arr[7].coords,
|
|
|
|
arr[8].coords,
|
|
|
|
arr[9].coords,
|
|
|
|
arr[10].coords,
|
|
|
|
arr[11].coords,
|
|
|
|
arr[12].coords,
|
|
|
|
arr[13].coords,
|
|
|
|
arr[14].coords,
|
|
|
|
arr[15].coords,
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 2]>
|
|
|
|
for UnitQuaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as simba::simd::SimdValue>::Element; 2]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [UnitQuaternion<N::Element>; 2]) -> Self {
|
|
|
|
Self::new_unchecked(Quaternion::from([arr[0].into_inner(), arr[1].into_inner()]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 4]>
|
|
|
|
for UnitQuaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as simba::simd::SimdValue>::Element; 4]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [UnitQuaternion<N::Element>; 4]) -> Self {
|
|
|
|
Self::new_unchecked(Quaternion::from([
|
|
|
|
arr[0].into_inner(),
|
|
|
|
arr[1].into_inner(),
|
|
|
|
arr[2].into_inner(),
|
|
|
|
arr[3].into_inner(),
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 8]>
|
|
|
|
for UnitQuaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as simba::simd::SimdValue>::Element; 8]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [UnitQuaternion<N::Element>; 8]) -> Self {
|
|
|
|
Self::new_unchecked(Quaternion::from([
|
|
|
|
arr[0].into_inner(),
|
|
|
|
arr[1].into_inner(),
|
|
|
|
arr[2].into_inner(),
|
|
|
|
arr[3].into_inner(),
|
|
|
|
arr[4].into_inner(),
|
|
|
|
arr[5].into_inner(),
|
|
|
|
arr[6].into_inner(),
|
|
|
|
arr[7].into_inner(),
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 16]>
|
|
|
|
for UnitQuaternion<N>
|
|
|
|
where
|
|
|
|
N: From<[<N as simba::simd::SimdValue>::Element; 16]>,
|
|
|
|
N::Element: Scalar + Copy,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(arr: [UnitQuaternion<N::Element>; 16]) -> Self {
|
|
|
|
Self::new_unchecked(Quaternion::from([
|
|
|
|
arr[0].into_inner(),
|
|
|
|
arr[1].into_inner(),
|
|
|
|
arr[2].into_inner(),
|
|
|
|
arr[3].into_inner(),
|
|
|
|
arr[4].into_inner(),
|
|
|
|
arr[5].into_inner(),
|
|
|
|
arr[6].into_inner(),
|
|
|
|
arr[7].into_inner(),
|
|
|
|
arr[8].into_inner(),
|
|
|
|
arr[9].into_inner(),
|
|
|
|
arr[10].into_inner(),
|
|
|
|
arr[11].into_inner(),
|
|
|
|
arr[12].into_inner(),
|
|
|
|
arr[13].into_inner(),
|
|
|
|
arr[14].into_inner(),
|
|
|
|
arr[15].into_inner(),
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|