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
|
|
|
|
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,
|
2021-01-29 07:46:14 +08:00
|
|
|
TAffine, Transform, Translation, UnitDualQuaternion, 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
|
2021-04-07 20:29:20 +08:00
|
|
|
* UnitQuaternion -> Rotation<3>
|
|
|
|
* UnitQuaternion -> Isometry<3>
|
2021-01-29 06:25:32 +08:00
|
|
|
* UnitQuaternion -> UnitDualQuaternion
|
2021-04-07 20:29:20 +08:00
|
|
|
* UnitQuaternion -> Similarity<3>
|
|
|
|
* UnitQuaternion -> Transform<3>
|
2016-12-05 05:44:42 +08:00
|
|
|
* UnitQuaternion -> Matrix<U4> (homogeneous)
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* UnitQuaternion -> Quaternion is already provided by: Unit<T> -> T
|
|
|
|
*/
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2> SubsetOf<Quaternion<T2>> for Quaternion<T1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2021-08-03 00:41:46 +08:00
|
|
|
T1: Scalar,
|
|
|
|
T2: Scalar + SupersetOf<T1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> Quaternion<T2> {
|
2018-10-28 14:33:39 +08:00
|
|
|
Quaternion::from(self.coords.to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(q: &Quaternion<T2>) -> bool {
|
|
|
|
crate::is_convertible::<_, Vector4<T1>>(&q.coords)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(q: &Quaternion<T2>) -> Self {
|
2018-10-28 14:33:39 +08:00
|
|
|
Self {
|
|
|
|
coords: q.coords.to_subset_unchecked(),
|
|
|
|
}
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2> SubsetOf<UnitQuaternion<T2>> for UnitQuaternion<T1>
|
2021-07-18 10:50:06 +08:00
|
|
|
where
|
2021-08-03 00:41:46 +08:00
|
|
|
T1: Scalar,
|
|
|
|
T2: Scalar + SupersetOf<T1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> UnitQuaternion<T2> {
|
2017-08-03 01:37:44 +08:00
|
|
|
UnitQuaternion::new_unchecked(self.as_ref().to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(uq: &UnitQuaternion<T2>) -> bool {
|
|
|
|
crate::is_convertible::<_, Quaternion<T1>>(uq.as_ref())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(uq: &UnitQuaternion<T2>) -> 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2> SubsetOf<Rotation<T2, 3>> for UnitQuaternion<T1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T1: RealField,
|
|
|
|
T2: RealField + SupersetOf<T1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2017-08-03 01:37:44 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> Rotation3<T2> {
|
|
|
|
let q: UnitQuaternion<T2> = self.to_superset();
|
2016-12-05 05:44:42 +08:00
|
|
|
q.to_rotation_matrix()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(rot: &Rotation3<T2>) -> bool {
|
|
|
|
crate::is_convertible::<_, Rotation3<T1>>(rot)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(rot: &Rotation3<T2>) -> Self {
|
|
|
|
let q = UnitQuaternion::<T2>::from_rotation_matrix(rot);
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::convert_unchecked(q)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2, R> SubsetOf<Isometry<T2, R, 3>> for UnitQuaternion<T1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T1: RealField,
|
|
|
|
T2: RealField + SupersetOf<T1>,
|
|
|
|
R: AbstractRotation<T2, 3> + SupersetOf<Self>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> Isometry<T2, R, 3> {
|
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]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(iso: &Isometry<T2, R, 3>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
iso.translation.vector.is_zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(iso: &Isometry<T2, R, 3>) -> Self {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::convert_ref_unchecked(&iso.rotation)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
2021-01-29 06:25:32 +08:00
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2> SubsetOf<UnitDualQuaternion<T2>> for UnitQuaternion<T1>
|
2021-01-29 06:25:32 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T1: RealField,
|
|
|
|
T2: RealField + SupersetOf<T1>,
|
2021-01-29 06:25:32 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> UnitDualQuaternion<T2> {
|
|
|
|
let q: UnitQuaternion<T2> = crate::convert_ref(self);
|
2021-01-29 06:25:32 +08:00
|
|
|
UnitDualQuaternion::from_rotation(q)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(dq: &UnitDualQuaternion<T2>) -> bool {
|
2021-01-29 06:25:32 +08:00
|
|
|
dq.translation().vector.is_zero()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(dq: &UnitDualQuaternion<T2>) -> Self {
|
2021-01-29 06:25:32 +08:00
|
|
|
crate::convert_unchecked(dq.rotation())
|
|
|
|
}
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2, R> SubsetOf<Similarity<T2, R, 3>> for UnitQuaternion<T1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T1: RealField,
|
|
|
|
T2: RealField + SupersetOf<T1>,
|
|
|
|
R: AbstractRotation<T2, 3> + SupersetOf<Self>,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> Similarity<T2, R, 3> {
|
|
|
|
Similarity::from_isometry(crate::convert_ref(self), T2::one())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(sim: &Similarity<T2, R, 3>) -> bool {
|
|
|
|
sim.isometry.translation.vector.is_zero() && sim.scaling() == T2::one()
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(sim: &Similarity<T2, R, 3>) -> Self {
|
2019-03-23 21:29:07 +08:00
|
|
|
crate::convert_ref_unchecked(&sim.isometry)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2, C> SubsetOf<Transform<T2, C, 3>> for UnitQuaternion<T1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T1: RealField,
|
|
|
|
T2: RealField + SupersetOf<T1>,
|
2018-02-02 19:26:35 +08:00
|
|
|
C: SuperTCategoryOf<TAffine>,
|
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> Transform<T2, C, 3> {
|
2021-08-04 23:34:25 +08:00
|
|
|
Transform::from_matrix_unchecked(self.clone().to_homogeneous().to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(t: &Transform<T2, C, 3>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
<Self as SubsetOf<_>>::is_in_subset(t.matrix())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(t: &Transform<T2, C, 3>) -> Self {
|
2016-12-05 05:44:42 +08:00
|
|
|
Self::from_superset_unchecked(t.matrix())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1: RealField, T2: RealField + SupersetOf<T1>> SubsetOf<Matrix4<T2>> for UnitQuaternion<T1> {
|
2017-08-03 01:37:44 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> Matrix4<T2> {
|
2021-08-04 23:34:25 +08:00
|
|
|
self.clone().to_homogeneous().to_superset()
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(m: &Matrix4<T2>) -> bool {
|
|
|
|
crate::is_convertible::<_, Rotation3<T1>>(m)
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(m: &Matrix4<T2>) -> Self {
|
|
|
|
let rot: Rotation3<T1> = 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
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: SimdRealField> From<UnitQuaternion<T>> for Matrix4<T>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2018-10-13 16:25:34 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(q: UnitQuaternion<T>) -> Self {
|
2018-10-13 16:25:34 +08:00
|
|
|
q.to_homogeneous()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: SimdRealField> From<UnitQuaternion<T>> for Rotation3<T>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2019-02-19 05:41:46 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(q: UnitQuaternion<T>) -> Self {
|
2019-02-19 05:41:46 +08:00
|
|
|
q.to_rotation_matrix()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: SimdRealField> From<Rotation3<T>> for UnitQuaternion<T>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2019-02-19 05:41:46 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(q: Rotation3<T>) -> Self {
|
2019-02-19 05:41:46 +08:00
|
|
|
Self::from_rotation_matrix(&q)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: SimdRealField> From<UnitQuaternion<T>> for Matrix3<T>
|
2020-04-06 00:49:48 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T::Element: SimdRealField,
|
2020-03-22 06:22:55 +08:00
|
|
|
{
|
2018-10-13 16:25:34 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(q: UnitQuaternion<T>) -> 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
|
|
|
|
2021-08-03 00:41:46 +08:00
|
|
|
impl<T: Scalar> From<Vector4<T>> for Quaternion<T> {
|
2018-10-28 14:33:39 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(coords: Vector4<T>) -> 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
|
|
|
|
2021-08-03 00:41:46 +08:00
|
|
|
impl<T: Scalar> From<[T; 4]> for Quaternion<T> {
|
2020-10-25 18:23:51 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(coords: [T; 4]) -> Self {
|
2020-10-25 18:23:51 +08:00
|
|
|
Self {
|
|
|
|
coords: coords.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<T::Element>; 2]> for Quaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as SimdValue>::Element; 2]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [Quaternion<T::Element>; 2]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
Self::from(Vector4::from([arr[0].coords, arr[1].coords]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<T::Element>; 4]> for Quaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as SimdValue>::Element; 4]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [Quaternion<T::Element>; 4]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
Self::from(Vector4::from([
|
|
|
|
arr[0].coords,
|
|
|
|
arr[1].coords,
|
|
|
|
arr[2].coords,
|
|
|
|
arr[3].coords,
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<T::Element>; 8]> for Quaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as SimdValue>::Element; 8]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [Quaternion<T::Element>; 8]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
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,
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + PrimitiveSimdValue> From<[Quaternion<T::Element>; 16]> for Quaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as SimdValue>::Element; 16]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [Quaternion<T::Element>; 16]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
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,
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<T::Element>; 2]>
|
|
|
|
for UnitQuaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as simba::simd::SimdValue>::Element; 2]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [UnitQuaternion<T::Element>; 2]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
Self::new_unchecked(Quaternion::from([arr[0].into_inner(), arr[1].into_inner()]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<T::Element>; 4]>
|
|
|
|
for UnitQuaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as simba::simd::SimdValue>::Element; 4]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [UnitQuaternion<T::Element>; 4]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
Self::new_unchecked(Quaternion::from([
|
|
|
|
arr[0].into_inner(),
|
|
|
|
arr[1].into_inner(),
|
|
|
|
arr[2].into_inner(),
|
|
|
|
arr[3].into_inner(),
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<T::Element>; 8]>
|
|
|
|
for UnitQuaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as simba::simd::SimdValue>::Element; 8]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [UnitQuaternion<T::Element>; 8]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
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(),
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<T::Element>; 16]>
|
|
|
|
for UnitQuaternion<T>
|
2020-03-23 16:16:01 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T: From<[<T as simba::simd::SimdValue>::Element; 16]>,
|
|
|
|
T::Element: Scalar + Copy,
|
2020-03-23 16:16:01 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(arr: [UnitQuaternion<T::Element>; 16]) -> Self {
|
2020-03-23 16:16:01 +08:00
|
|
|
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(),
|
|
|
|
]))
|
|
|
|
}
|
|
|
|
}
|