src/ascension/datatypes.h

changeset 217
4b3c974eab44
parent 216
943980fa37b5
equal deleted inserted replaced
216:943980fa37b5 217:4b3c974eab44
231 } else { 231 } else {
232 return x; 232 return x;
233 } 233 }
234 } 234 }
235 235
236 static inline int asc_sgn(int x) {
237 return x < 0 ? -1 : 1;
238 }
239
240 static inline int asc_sgnf(float x) {
241 return asc_fround_zero(x) < 0 ? -1 : 1;
242 }
243
236 /** 244 /**
237 * Returns the cosine of x. 245 * Returns the cosine of x.
238 * 246 *
239 * This function eliminates result values close to zero. 247 * This function eliminates result values close to zero.
240 * 248 *
295 } 303 }
296 304
297 // -------------------------------------------------------------------------- 305 // --------------------------------------------------------------------------
298 // Vector Functions 306 // Vector Functions
299 // -------------------------------------------------------------------------- 307 // --------------------------------------------------------------------------
308
309 static inline asc_vec2i asc_vec2_ftoi(asc_vec2f v) {
310 return ASC_VEC2I(v.x, v.y);
311 }
312
313 static inline asc_vec2f asc_vec2_itof(asc_vec2i v) {
314 return ASC_VEC2F(v.x, v.y);
315 }
316
317 static inline asc_vec2u asc_vec2_ftou(asc_vec2f v) {
318 return ASC_VEC2U(v.x, v.y);
319 }
320
321 static inline asc_vec2f asc_vec2_utof(asc_vec2u v) {
322 return ASC_VEC2F(v.x, v.y);
323 }
300 324
301 static inline asc_vec2f asc_vec2f_scale(asc_vec2f v, float s) { 325 static inline asc_vec2f asc_vec2f_scale(asc_vec2f v, float s) {
302 return ASC_VEC2F(v.x*s, v.y*s); 326 return ASC_VEC2F(v.x*s, v.y*s);
303 } 327 }
304 328

mercurial