nalgebra/third_party/glam/common/
glam_similarity.rs1use super::glam::{DMat3, DMat4, Mat3, Mat4};
2use crate::{Matrix3, Matrix4, Similarity2, Similarity3};
3use std::convert::TryFrom;
4
5impl From<Similarity2<f32>> for Mat3 {
6 fn from(iso: Similarity2<f32>) -> Mat3 {
7 iso.to_homogeneous().into()
8 }
9}
10impl From<Similarity3<f32>> for Mat4 {
11 fn from(iso: Similarity3<f32>) -> Mat4 {
12 iso.to_homogeneous().into()
13 }
14}
15
16impl From<Similarity2<f64>> for DMat3 {
17 fn from(iso: Similarity2<f64>) -> DMat3 {
18 iso.to_homogeneous().into()
19 }
20}
21impl From<Similarity3<f64>> for DMat4 {
22 fn from(iso: Similarity3<f64>) -> DMat4 {
23 iso.to_homogeneous().into()
24 }
25}
26
27impl TryFrom<Mat3> for Similarity2<f32> {
28 type Error = ();
29 fn try_from(mat3: Mat3) -> Result<Similarity2<f32>, ()> {
30 crate::try_convert(Matrix3::from(mat3)).ok_or(())
31 }
32}
33
34impl TryFrom<Mat4> for Similarity3<f32> {
35 type Error = ();
36 fn try_from(mat4: Mat4) -> Result<Similarity3<f32>, ()> {
37 crate::try_convert(Matrix4::from(mat4)).ok_or(())
38 }
39}
40
41impl TryFrom<DMat3> for Similarity2<f64> {
42 type Error = ();
43 fn try_from(mat3: DMat3) -> Result<Similarity2<f64>, ()> {
44 crate::try_convert(Matrix3::from(mat3)).ok_or(())
45 }
46}
47
48impl TryFrom<DMat4> for Similarity3<f64> {
49 type Error = ();
50 fn try_from(mat4: DMat4) -> Result<Similarity3<f64>, ()> {
51 crate::try_convert(Matrix4::from(mat4)).ok_or(())
52 }
53}