- english
- /
- japanese
functions
- ofAngleDifferenceDegrees()
- ofAngleDifferenceRadians()
- ofAngleSumRadians()
- ofBezierPoint()
- ofBezierTangent()
- ofClamp()
- ofCurvePoint()
- ofCurveTangent()
- ofDegToRad()
- ofDist()
- ofDistSquared()
- ofInRange()
- ofInsidePoly()
- ofLerp()
- ofLerpDegrees()
- ofLerpRadians()
- ofLineSegmentIntersection()
- ofMap()
- ofNextPow2()
- ofNoise()
- ofNormalize()
- ofRadToDeg()
- ofRandom()
- ofRandomHeight()
- ofRandomWidth()
- ofRandomf()
- ofRandomuf()
- ofSeedRandom()
- ofSign()
- ofSignedNoise()
- ofWrapDegrees()
- ofWrapRadians()
ofClamp(...)
float ofClamp(float value, float min, float max)
Restricts a value to be within a specified range defined by values min and max. e.g:
float val, newval;
val=10;
newval=ofClamp(val,30,40); //newval = 30
newval=ofClamp(val,0,5); //newval = 5
newval=ofClamp(val,0,20); //newval = 10
ofDegToRad(...)
float ofDegToRad(float degrees)
Convert an angle value expressed in Degrees into an angle in Radians. For example if we call this function for degrees=90 we obtain PI/2.
ofDist(...)
float ofDist(float x1, float y1, float x2, float y2 )
Calculates the distance between two points, (x1, y1) and (x2, y2). Uses http://en.wikipedia.org/wiki/Pythagorean_theorem
ofDistSquared(...)
float ofDistSquared(float x1, float y1, float x2, float y2 )
Calculates the distances between two points, as in ofDist() but doesn't take the sqrt() of the result, which is a faster operation if you need to calculate and compare multiple distances.
ofInRange(...)
bool ofInRange(float t, float min, float max)
Returns true if the number t is the range of [min - max], false if it's not.
ofLerp(...)
float ofLerp(float start, float stop, float amt)
Calculates a number between two numbers (start,stop) at a specific increment (amt). If we want the new number to be between start,stop numbers amp needs to be a number between 0 and 1. e.g:
float init,end,increment,result;
increment=0.2;
init = 1;
end =2;
result=ofLerp(init, end, increment); //result = 1.2
//We are doing init+increment*(end-init)
ofLineSegmentIntersection(...)
bool ofLineSegmentIntersection(ofPoint line1Start, ofPoint line1End, ofPoint line2Start, ofPoint line2End, ofPoint &intersection)
ofMap(...)
float ofMap(float value, float inputMin, float inputMax, float outputMin, float outputMax)
Re-maps a number from one range to another. We convert the number value where inputMin < value < inputMax into a number beetween outputMin and outputMax. e.g:
float x, newx;
x=5;
// 0 < x < 10
newx = ofMap(x, 0, 10, 21, 22) //newx = 21.5 a value between 21 and 22
ofMap(...)
float ofMap(float value, float inputMin, float inputMax, float outputMin, float outputMax, bool clamp=false)
ofMap remaps the value passed in "value", calculating it's linear distance between inputMin and inputMax, and remapping it based on that percentage to outputMin and outputMax. You can choose to clamp the results. Results are not clamped by default. For example: float color = ofMap(mouseX, 0, ofGetWidth(), 0, 255, true); ofBackground(color, color, color);
ofNextPow2(...)
int ofNextPow2(int a)
eg: for an input of 50 ofNextPow2 will return 64 and for an input of 401 it will return 512.
ofNormalize(...)
float ofNormalize(float value, float min, float max)
Normalizes a number from a given range (min,max) into a value between 0 and 1. note: we are getting a clamp number between 0 and 1 of "value-min/max-min"
ofRadToDeg(...)
float ofRadToDeg(float radians)
Convert an angle value expressed in Radians into an angle in Degrees. For example if we call this function for radians=PI/2 we obtain 90.
ofRandom(...)
float ofRandom(float val0, float val1)
For example, ofRandom(-30,20) will return a random float point number between -30 and 20.
ofSeedRandom()
void ofSeedRandom()
Seeds the random number generator to the clock time, so that random numbers will always be different.
ofSeedRandom(...)
void ofSeedRandom(int val)
Seeds the random number generator to a value passed in (val), so that random numbers will always be the same using the same seed.
Last updated
Thursday, 16 May 2013 14:01:12 UTC
-
cbf0910627a25e6153f2452833c5313fe6067059


