Changeset 1341
- Timestamp:
- May 5, 2012, 5:16:29 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lol/math/vector.h
r1323 r1341 1104 1104 /* 1105 1105 * vec *(vec, scalar) (also complex & quaternion) 1106 * vec *(scalar, vec) (also complex & quaternion)1107 1106 * vec /(vec, scalar) (also complex & quaternion) 1108 * vec /(scalar, vec) (also complex & quaternion)1109 1107 */ 1110 1108 #define DECLARE_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \ … … 1116 1114 ret[n] = a[n] op val; \ 1117 1115 return ret; \ 1118 } \ 1119 \ 1116 } 1117 1118 /* 1119 * vec *(scalar, vec) (also complex & quaternion) 1120 * vec /(scalar, vec) (NOT for complex & quaternion!) 1121 */ 1122 #define DECLARE_SCALAR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \ 1120 1123 tprefix \ 1121 1124 inline tname<tf> operator op(t1 const &val, tname<t2> const &a) \ … … 1171 1174 } 1172 1175 1173 #define DECLARE_BINARY_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1174 DECLARE_VECTOR_SCALAR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1175 DECLARE_VECTOR_SCALAR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1176 \ 1176 #define DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1177 1177 DECLARE_VECTOR_VECTOR_COERCE_OP(tname, -, tprefix, t1, t2, tf) \ 1178 1178 DECLARE_VECTOR_VECTOR_COERCE_OP(tname, +, tprefix, t1, t2, tf) \ 1179 1179 \ 1180 DECLARE_VECTOR_SCALAR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1181 DECLARE_VECTOR_SCALAR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1182 DECLARE_SCALAR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \ 1183 \ 1180 1184 DECLARE_VECTOR_VECTOR_BOOLOP(tname, ==, ==, true, tprefix, t1, t2) \ 1181 DECLARE_VECTOR_VECTOR_BOOLOP(tname, !=, ==, false, tprefix, t1, t2) \ 1185 DECLARE_VECTOR_VECTOR_BOOLOP(tname, !=, ==, false, tprefix, t1, t2) 1186 1187 #define DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ 1188 DECLARE_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \ 1182 1189 \ 1183 1190 tprefix \ … … 1199 1206 } 1200 1207 1201 #define DECLARE_BINARY_OPS(tname, tprefix, type) \ 1202 DECLARE_BINARY_COERCE_OPS(tname, tprefix, type, type, type) \ 1203 \ 1204 DECLARE_VECTOR_SCALAR_OP(tname, *, tprefix, type) \ 1205 DECLARE_VECTOR_SCALAR_OP(tname, /, tprefix, type) \ 1208 #define DECLARE_BINARY_NONVECTOR_OPS(tname, tprefix, type) \ 1209 DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, type, type, type) \ 1206 1210 \ 1207 1211 DECLARE_VECTOR_VECTOR_OP(tname, -, tprefix, type) \ 1208 1212 DECLARE_VECTOR_VECTOR_OP(tname, +, tprefix, type) \ 1213 \ 1214 DECLARE_VECTOR_SCALAR_OP(tname, *, tprefix, type) \ 1215 DECLARE_VECTOR_SCALAR_OP(tname, /, tprefix, type) 1216 1217 #define DECLARE_BINARY_VECTOR_OPS(tname, tprefix, type) \ 1218 DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, type, type, type) \ 1209 1219 \ 1210 1220 DECLARE_VECTOR_MINMAX_OP(tname, min, tprefix, type) \ … … 1228 1238 1229 1239 #define DECLARE_ALL_NONVECTOR_OPS(tname) \ 1230 DECLARE_BINARY_ OPS(tname, template<typename T> static, T) \1240 DECLARE_BINARY_NONVECTOR_OPS(tname, template<typename T> static, T) \ 1231 1241 DECLARE_UNARY_OPS(tname, template<typename T> static, T) 1232 1242 1233 1243 #define DECLARE_ALL_VECTOR_OPS_INNER(tname, type) \ 1234 DECLARE_BINARY_OPS(tname, static, type) \ 1244 DECLARE_BINARY_VECTOR_OPS(tname, static, type) \ 1245 DECLARE_BINARY_NONVECTOR_OPS(tname, static, type) \ 1235 1246 DECLARE_UNARY_OPS(tname, static, type) \ 1236 1247 DECLARE_VECTOR_OPS(tname, static, type) \ … … 1247 1258 1248 1259 #define DECLARE_VEC_ANY_COERCE_OPS(tname, tlow, thigh) \ 1249 DECLARE_BINARY_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1250 DECLARE_BINARY_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1260 DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1261 DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1262 DECLARE_BINARY_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ 1263 DECLARE_BINARY_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \ 1251 1264 \ 1252 1265 DECLARE_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \ … … 1467 1480 #undef DECLARE_VECTOR_VECTOR_BOOLOP 1468 1481 #undef DECLARE_VECTOR_SCALAR_OP 1469 #undef DECLARE_BINARY_OPS 1482 #undef DECLARE_BINARY_VECTOR_OPS 1483 #undef DECLARE_BINARY_NONVECTOR_OPS 1470 1484 #undef DECLARE_UNARY_OPS 1471 1485 #undef DECLARE_ALL_NONVECTOR_OPS -
trunk/test/unit/quat.cpp
r1318 r1341 117 117 quat a(2.f, -2.f, -8.f, 3.f); 118 118 quat b = re(a); 119 quat c = 1.f / a; 120 121 LOLUNIT_ASSERT_DOUBLES_EQUAL(b.w, c.w, 1e-5); 122 LOLUNIT_ASSERT_DOUBLES_EQUAL(b.x, c.x, 1e-5); 123 LOLUNIT_ASSERT_DOUBLES_EQUAL(b.y, c.y, 1e-5); 124 LOLUNIT_ASSERT_DOUBLES_EQUAL(b.z, c.z, 1e-5); 119 125 120 126 quat m1 = a * b;
Note: See TracChangeset
for help on using the changeset viewer.