Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct mat<4, 4, T, Q>
- {
- typedef vec<4, T, Q> col_type;
- typedef vec<4, T, Q> row_type;
- typedef mat<4, 4, T, Q> type;
- typedef mat<4, 4, T, Q> transpose_type;
- typedef T value_type;
- };
- template<typename T, qualifier Q>
- GLM_FUNC_QUALIFIER mat<4, 4, T, Q> rotate(mat<4, 4, T, Q> const& m, T angle, vec<3, T, Q> const& v)
- {
- T const a = angle;
- T const c = cos(a);
- T const s = sin(a);
- vec<3, T, Q> axis(normalize(v));
- vec<3, T, Q> temp((T(1) - c) * axis);
- mat<4, 4, T, Q> Rotate;
- Rotate[0][0] = c + temp[0] * axis[0];
- Rotate[0][1] = temp[0] * axis[1] + s * axis[2];
- Rotate[0][2] = temp[0] * axis[2] - s * axis[1];
- Rotate[1][0] = temp[1] * axis[0] - s * axis[2];
- Rotate[1][1] = c + temp[1] * axis[1];
- Rotate[1][2] = temp[1] * axis[2] + s * axis[0];
- Rotate[2][0] = temp[2] * axis[0] + s * axis[1];
- Rotate[2][1] = temp[2] * axis[1] - s * axis[0];
- Rotate[2][2] = c + temp[2] * axis[2];
- mat<4, 4, T, Q> Result;
- Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
- Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
- Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
- Result[3] = m[3];
- return Result;
- }
- struct compute_transpose<2, 2, T, Q, Aligned>
- {
- GLM_FUNC_QUALIFIER static mat<2, 2, T, Q> call(mat<2, 2, T, Q> const& m)
- {
- mat<2, 2, T, Q> Result;
- Result[0][0] = m[0][0];
- Result[0][1] = m[1][0];
- Result[1][0] = m[0][1];
- Result[1][1] = m[1][1];
- return Result;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement