@@ -45,34 +45,36 @@ namespace glm
4545 return m * r;
4646 }
4747
48- // template<typename T, qualifier Q>
49- // GLM_FUNC_QUALIFIER mat<3, 3, T, Q> reflect2D(mat<3, 3, T, Q> const& m, vec<3, T, Q> const& normal)
50- // {
51- // mat<3, 3, T, Q> r(static_cast<T>(1));
52- // r[0][0] = static_cast<T>(1) - static_cast<T>(2) * normal.x * normal.x;
53- // r[0][1] = -static_cast<T>(2) * normal.x * normal.y;
54- // r[1][0] = -static_cast<T>(2) * normal.x * normal.y;
55- // r[1][1] = static_cast<T>(1) - static_cast<T>(2) * normal.y * normal.y;
56- // return m * r;
57- // }
48+ template <typename T, qualifier Q>
49+ GLM_FUNC_QUALIFIER mat<3 , 3 , T, Q> reflect2D (mat<3 , 3 , T, Q> const & m, vec<2 , T, Q> const & normal, T distance)
50+ {
51+ mat<3 , 3 , T, Q> r (static_cast <T>(1 ));
52+ r[0 ][0 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.x * normal.x ;
53+ r[0 ][1 ] = -static_cast <T>(2 ) * normal.y * normal.x ;
54+ r[1 ][0 ] = -static_cast <T>(2 ) * normal.x * normal.y ;
55+ r[1 ][1 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.y * normal.y ;
56+ r[2 ][0 ] = -static_cast <T>(2 ) * normal.x * distance;
57+ r[2 ][1 ] = -static_cast <T>(2 ) * normal.y * distance;
58+ return m * r;
59+ }
5860
5961 template <typename T, qualifier Q>
60- GLM_FUNC_DECL mat<4 , 4 , T, Q> reflect3D (vec<3 , T, Q> const & normal, T distance)
62+ GLM_FUNC_QUALIFIER mat<4 , 4 , T, Q> reflect3D (mat< 4 , 4 , T, Q> const & m, vec<3 , T, Q> const & normal, T distance)
6163 {
62- mat<4 , 4 , T, Q> result (static_cast <T>(1 ));
63- result [0 ][0 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.x * normal.x ;
64- result [0 ][1 ] = -static_cast <T>(2 ) * normal.y * normal.x ;
65- result [0 ][2 ] = -static_cast <T>(2 ) * normal.z * normal.x ;
66- result [1 ][0 ] = -static_cast <T>(2 ) * normal.x * normal.y ;
67- result [1 ][1 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.y * normal.y ;
68- result [1 ][2 ] = -static_cast <T>(2 ) * normal.z * normal.y ;
69- result [2 ][0 ] = -static_cast <T>(2 ) * normal.x * normal.z ;
70- result [2 ][1 ] = -static_cast <T>(2 ) * normal.y * normal.z ;
71- result [2 ][2 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.z * normal.z ;
72- result [3 ][0 ] = -static_cast <T>(2 ) * normal.x * distance;
73- result [3 ][1 ] = -static_cast <T>(2 ) * normal.y * distance;
74- result [3 ][2 ] = -static_cast <T>(2 ) * normal.z * distance;
75- return result ;
64+ mat<4 , 4 , T, Q> r (static_cast <T>(1 ));
65+ r [0 ][0 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.x * normal.x ;
66+ r [0 ][1 ] = -static_cast <T>(2 ) * normal.y * normal.x ;
67+ r [0 ][2 ] = -static_cast <T>(2 ) * normal.z * normal.x ;
68+ r [1 ][0 ] = -static_cast <T>(2 ) * normal.x * normal.y ;
69+ r [1 ][1 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.y * normal.y ;
70+ r [1 ][2 ] = -static_cast <T>(2 ) * normal.z * normal.y ;
71+ r [2 ][0 ] = -static_cast <T>(2 ) * normal.x * normal.z ;
72+ r [2 ][1 ] = -static_cast <T>(2 ) * normal.y * normal.z ;
73+ r [2 ][2 ] = static_cast <T>(1 ) - static_cast <T>(2 ) * normal.z * normal.z ;
74+ r [3 ][0 ] = -static_cast <T>(2 ) * normal.x * distance;
75+ r [3 ][1 ] = -static_cast <T>(2 ) * normal.y * distance;
76+ r [3 ][2 ] = -static_cast <T>(2 ) * normal.z * distance;
77+ return m * r ;
7678 }
7779
7880 template <typename T, qualifier Q>
0 commit comments