Changeset 2192
- Timestamp:
- Jan 2, 2013, 1:53:39 PM (10 years ago)
- Location:
- trunk/src/lol/math
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lol/math/half.h
r2183 r2192 126 126 return (half)fmod((float)a, (float)b); 127 127 } 128 static inline half fract(half a) { return (half)fract((float)a); } 128 129 static inline half abs(half a) { return half::makebits(a.bits & 0x7fffu); } 129 130 -
trunk/src/lol/math/math.h
r2188 r2192 33 33 static inline double sqrt(double const &x) { return std::sqrt(x); } 34 34 static inline float sqrt(float const &x) { return std::sqrt(x); } 35 36 static inline double exp(double const &x) { return std::exp(x); } 37 static inline float exp(float const &x) { return std::exp(x); } 35 38 36 39 static inline double sin(double const &x) { return std::sin(x); } … … 139 142 static inline ldouble fmod(ldouble x, ldouble y) { return std::fmod(x, y); } 140 143 144 static inline uint8_t fract(uint8_t x) { return 0; } 145 static inline int8_t fract(int8_t x) { return 0; } 146 static inline uint16_t fract(uint16_t x) { return 0; } 147 static inline int16_t fract(int16_t x) { return 0; } 148 static inline uint32_t fract(uint32_t x) { return 0; } 149 static inline int32_t fract(int32_t x) { return 0; } 150 static inline uint64_t fract(uint64_t x) { return 0; } 151 static inline int64_t fract(int64_t x) { return 0; } 152 static inline float fract(float x) { return x - std::floor(x); } 153 static inline double fract(double x) { return x - std::floor(x); } 154 static inline ldouble fract(ldouble x) { return x - std::floor(x); } 155 141 156 static inline uint8_t min(uint8_t x, uint8_t y) { return std::min(x, y); } 142 157 static inline int8_t min(int8_t x, int8_t y) { return std::min(x, y); } -
trunk/src/lol/math/vector.h
r2183 r2192 1136 1136 1137 1137 /* 1138 * vec mix(vec, vec, vec) 1139 * vec mix(vec, vec, scalar) 1140 */ 1141 #define LOL_VECTOR_MIX_FUN(tname, tprefix, type) \ 1142 tprefix \ 1143 inline tname<type> mix(tname<type> const &x, \ 1144 tname<type> const &y, tname<type> const &a) \ 1145 { \ 1146 return x + a * (y - x); \ 1147 } \ 1148 \ 1149 tprefix \ 1150 inline tname<type> mix(tname<type> const &x, \ 1151 tname<type> const &y, type const &a) \ 1152 { \ 1153 return x + a * (y - x); \ 1154 } 1155 1156 /* 1138 1157 * bool ==(vec, vec) (also complex & quaternion) 1139 1158 * bool !=(vec, vec) (also complex & quaternion) … … 1216 1235 { \ 1217 1236 return (type)sqrt((double)sqlength(a)); \ 1237 } \ 1238 \ 1239 tprefix \ 1240 inline tname<type> fract(tname<type> const &a) \ 1241 { \ 1242 tname<type> ret; \ 1243 for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ 1244 ret[n] = fract(a[n]); \ 1245 return ret; \ 1218 1246 } \ 1219 1247 \ … … 1294 1322 LOL_VECTOR_MINMAX_FUN(tname, max, tprefix, type) \ 1295 1323 LOL_VECTOR_MINMAX_FUN(tname, fmod, tprefix, type) \ 1296 LOL_VECTOR_CLAMP_FUN(tname, tprefix, type) 1324 LOL_VECTOR_CLAMP_FUN(tname, tprefix, type) \ 1325 LOL_VECTOR_MIX_FUN(tname, tprefix, type) 1297 1326 1298 1327 #define LOL_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \ … … 1564 1593 #undef LOL_VECTOR_MINMAX_FUN 1565 1594 #undef LOL_VECTOR_CLAMP_FUN 1595 #undef LOL_VECTOR_MIX_FUN 1566 1596 #undef LOL_VECTOR_VECTOR_BOOL_OP 1567 1597 #undef LOL_VECTOR_SCALAR_COERCE_OP
Note: See TracChangeset
for help on using the changeset viewer.