| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | #pragma once |
| 17 | |
| 18 | |
| 19 | #include "../glm.hpp" |
| 20 | #include "../gtc/constants.hpp" |
| 21 | #include "../gtc/quaternion.hpp" |
| 22 | |
| 23 | #ifndef GLM_ENABLE_EXPERIMENTAL |
| 24 | # error "GLM: GLM_GTX_dual_quaternion is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it." |
| 25 | #endif |
| 26 | |
| 27 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) |
| 28 | # pragma message("GLM: GLM_GTX_dual_quaternion extension included") |
| 29 | #endif |
| 30 | |
| 31 | namespace glm |
| 32 | { |
| 33 | |
| 34 | |
| 35 | |
| 36 | template<typename T, qualifier Q = defaultp> |
| 37 | struct tdualquat |
| 38 | { |
| 39 | |
| 40 | |
| 41 | typedef T value_type; |
| 42 | typedef qua<T, Q> part_type; |
| 43 | |
| 44 | |
| 45 | |
| 46 | qua<T, Q> real, dual; |
| 47 | |
| 48 | |
| 49 | |
| 50 | typedef length_t length_type; |
| 51 | |
| 52 | GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 2;} |
| 53 | |
| 54 | GLM_FUNC_DECL part_type & operator[](length_type i); |
| 55 | GLM_FUNC_DECL part_type const& operator[](length_type i) const; |
| 56 | |
| 57 | |
| 58 | |
| 59 | GLM_FUNC_DECL GLM_CONSTEXPR tdualquat() GLM_DEFAULT; |
| 60 | GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, Q> const& d) GLM_DEFAULT; |
| 61 | template<qualifier P> |
| 62 | GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(tdualquat<T, P> const& d); |
| 63 | |
| 64 | |
| 65 | |
| 66 | GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real); |
| 67 | GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& orientation, vec<3, T, Q> const& translation); |
| 68 | GLM_FUNC_DECL GLM_CONSTEXPR tdualquat(qua<T, Q> const& real, qua<T, Q> const& dual); |
| 69 | |
| 70 | |
| 71 | |
| 72 | template<typename U, qualifier P> |
| 73 | GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tdualquat(tdualquat<U, P> const& q); |
| 74 | |
| 75 | GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<2, 4, T, Q> const& holder_mat); |
| 76 | GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR tdualquat(mat<3, 4, T, Q> const& aug_mat); |
| 77 | |
| 78 | |
| 79 | |
| 80 | GLM_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<T, Q> const& m) GLM_DEFAULT; |
| 81 | |
| 82 | template<typename U> |
| 83 | GLM_FUNC_DECL tdualquat<T, Q> & operator=(tdualquat<U, Q> const& m); |
| 84 | template<typename U> |
| 85 | GLM_FUNC_DECL tdualquat<T, Q> & operator*=(U s); |
| 86 | template<typename U> |
| 87 | GLM_FUNC_DECL tdualquat<T, Q> & operator/=(U s); |
| 88 | }; |
| 89 | |
| 90 | |
| 91 | |
| 92 | template<typename T, qualifier Q> |
| 93 | GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q); |
| 94 | |
| 95 | template<typename T, qualifier Q> |
| 96 | GLM_FUNC_DECL tdualquat<T, Q> operator-(tdualquat<T, Q> const& q); |
| 97 | |
| 98 | |
| 99 | |
| 100 | template<typename T, qualifier Q> |
| 101 | GLM_FUNC_DECL tdualquat<T, Q> operator+(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p); |
| 102 | |
| 103 | template<typename T, qualifier Q> |
| 104 | GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, tdualquat<T, Q> const& p); |
| 105 | |
| 106 | template<typename T, qualifier Q> |
| 107 | GLM_FUNC_DECL vec<3, T, Q> operator*(tdualquat<T, Q> const& q, vec<3, T, Q> const& v); |
| 108 | |
| 109 | template<typename T, qualifier Q> |
| 110 | GLM_FUNC_DECL vec<3, T, Q> operator*(vec<3, T, Q> const& v, tdualquat<T, Q> const& q); |
| 111 | |
| 112 | template<typename T, qualifier Q> |
| 113 | GLM_FUNC_DECL vec<4, T, Q> operator*(tdualquat<T, Q> const& q, vec<4, T, Q> const& v); |
| 114 | |
| 115 | template<typename T, qualifier Q> |
| 116 | GLM_FUNC_DECL vec<4, T, Q> operator*(vec<4, T, Q> const& v, tdualquat<T, Q> const& q); |
| 117 | |
| 118 | template<typename T, qualifier Q> |
| 119 | GLM_FUNC_DECL tdualquat<T, Q> operator*(tdualquat<T, Q> const& q, T const& s); |
| 120 | |
| 121 | template<typename T, qualifier Q> |
| 122 | GLM_FUNC_DECL tdualquat<T, Q> operator*(T const& s, tdualquat<T, Q> const& q); |
| 123 | |
| 124 | template<typename T, qualifier Q> |
| 125 | GLM_FUNC_DECL tdualquat<T, Q> operator/(tdualquat<T, Q> const& q, T const& s); |
| 126 | |
| 127 | |
| 128 | |
| 129 | template<typename T, qualifier Q> |
| 130 | GLM_FUNC_DECL bool operator==(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2); |
| 131 | |
| 132 | template<typename T, qualifier Q> |
| 133 | GLM_FUNC_DECL bool operator!=(tdualquat<T, Q> const& q1, tdualquat<T, Q> const& q2); |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | template <typename T, qualifier Q> |
| 139 | GLM_FUNC_DECL tdualquat<T, Q> dual_quat_identity(); |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | template<typename T, qualifier Q> |
| 145 | GLM_FUNC_DECL tdualquat<T, Q> normalize(tdualquat<T, Q> const& q); |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | template<typename T, qualifier Q> |
| 151 | GLM_FUNC_DECL tdualquat<T, Q> lerp(tdualquat<T, Q> const& x, tdualquat<T, Q> const& y, T const& a); |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | template<typename T, qualifier Q> |
| 157 | GLM_FUNC_DECL tdualquat<T, Q> inverse(tdualquat<T, Q> const& q); |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | template<typename T, qualifier Q> |
| 163 | GLM_FUNC_DECL mat<2, 4, T, Q> mat2x4_cast(tdualquat<T, Q> const& x); |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | template<typename T, qualifier Q> |
| 169 | GLM_FUNC_DECL mat<3, 4, T, Q> mat3x4_cast(tdualquat<T, Q> const& x); |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | template<typename T, qualifier Q> |
| 175 | GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<2, 4, T, Q> const& x); |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | template<typename T, qualifier Q> |
| 181 | GLM_FUNC_DECL tdualquat<T, Q> dualquat_cast(mat<3, 4, T, Q> const& x); |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | typedef tdualquat<float, lowp> lowp_dualquat; |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | typedef tdualquat<float, mediump> mediump_dualquat; |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | typedef tdualquat<float, highp> highp_dualquat; |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | typedef tdualquat<float, lowp> lowp_fdualquat; |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | typedef tdualquat<float, mediump> mediump_fdualquat; |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | typedef tdualquat<float, highp> highp_fdualquat; |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | typedef tdualquat<double, lowp> lowp_ddualquat; |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | typedef tdualquat<double, mediump> mediump_ddualquat; |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | typedef tdualquat<double, highp> highp_ddualquat; |
| 230 | |
| 231 | |
| 232 | #if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) |
| 233 | |
| 234 | |
| 235 | |
| 236 | typedef highp_fdualquat dualquat; |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | typedef highp_fdualquat fdualquat; |
| 242 | #elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) |
| 243 | typedef highp_fdualquat dualquat; |
| 244 | typedef highp_fdualquat fdualquat; |
| 245 | #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT)) |
| 246 | typedef mediump_fdualquat dualquat; |
| 247 | typedef mediump_fdualquat fdualquat; |
| 248 | #elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT)) |
| 249 | typedef lowp_fdualquat dualquat; |
| 250 | typedef lowp_fdualquat fdualquat; |
| 251 | #else |
| 252 | # error "GLM error: multiple default precision requested for single-precision floating-point types" |
| 253 | #endif |
| 254 | |
| 255 | |
| 256 | #if(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) |
| 257 | |
| 258 | |
| 259 | |
| 260 | typedef highp_ddualquat ddualquat; |
| 261 | #elif(defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) |
| 262 | typedef highp_ddualquat ddualquat; |
| 263 | #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && defined(GLM_PRECISION_MEDIUMP_DOUBLE) && !defined(GLM_PRECISION_LOWP_DOUBLE)) |
| 264 | typedef mediump_ddualquat ddualquat; |
| 265 | #elif(!defined(GLM_PRECISION_HIGHP_DOUBLE) && !defined(GLM_PRECISION_MEDIUMP_DOUBLE) && defined(GLM_PRECISION_LOWP_DOUBLE)) |
| 266 | typedef lowp_ddualquat ddualquat; |
| 267 | #else |
| 268 | # error "GLM error: Multiple default precision requested for double-precision floating-point types" |
| 269 | #endif |
| 270 | |
| 271 | |
| 272 | } |
| 273 | |
| 274 | #include "dual_quaternion.inl" |