topical media & game development

talk show tell print

lib-of-vs-libs-openFrameworks-utils-ofMath.h / h



  
  // notes:
  // -----------------------------------------------------------
  // for fast things look here: http://musicdsp.org/archive.php?classid=5#115
  // -----------------------------------------------------------
  // the random () calls are based on misconceptions described here:
  // http://www.azillionmonkeys.com/qed/random.html
  // (Bad advice from C.L.C. FAQ)
  // we should correct this -- 
  // -----------------------------------------------------------
  
  ifndef _OF_MATH_H
  define _OF_MATH_H
  
  include <ofConstants.h>
  
  int                 ofNextPow2 ( int a );
  void                 ofSeedRandom();
  void                 ofSeedRandom(int val);
  float                 ofRandom(float val0, float val1);                // random (x - y)
  float                 ofRandomf();                                                        // random (-1 - 1)
  float                 ofRandomuf();                                                        // random (0 - 1) 
  
  float                ofNormalize(float value, float min, float max);
  float                ofMap(float value, float inputMin, float inputMax, float outputMin, float outputMax);
  float                ofClamp(float value, float min, float max);
  float                ofLerp(float start, float stop, float amt);
  float                ofDist(float x1, float y1, float x2, float y2);
  float                ofDistSquared(float x1, float y1, float x2, float y2);
  int                        ofSign(float n);
  bool                ofInRange(float t, float min, float max);
  float                ofRadToDeg(float radians);
  float                ofDegToRad(float degrees);
  float                ofRandomWidth();
  float                ofRandomHeight();
  
  endif
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.