#functions ##Description ###float ofAngleDifferenceDegrees(currentAngle, targetAngle) _inlined_description: _ Calculates the difference between two angles in degrees. This will calculate the actual difference, taking into account multiple revolutions. For example: ~~~~{.cpp} ofAngleDifferenceDegrees(0, 90); // Returns 90. ofAngleDifferenceDegrees(0, 450); // Also returns 90. ~~~~ **Parameters:** currentAngle The current angle in degrees. targetAngle the angle to be compared to in degrees. **Returns**: The difference between two angles in degrees. _description: _ ###float ofAngleDifferenceRadians(currentAngle, targetAngle) _inlined_description: _ Calculates the difference between two angles in radians. This will calculate the actual difference, taking into account multiple revolutions. For example: ~~~~{.cpp} ofAngleDifferenceRadians(0, PI); // Returns -PI. ofAngleDifferenceRadians(0, 3*PI); // Also returns -PI. ~~~~ **Parameters:** currentAngle The current angle in radians. targetAngle the angle to be compared to in radians. **Returns**: The difference between two angles in radians. _description: _ ###vectype ofBezierPoint(&a, &b, &c, &d, t) _inlined_description: _ Given the four points that determine a bezier curve, return an interpolated point on the curve. **Parameters:** a The beginning point of the curve. b The first control point. c The second control point. d The end point of the curve. t an offset along the curve, normalized between 0 and 1. **Returns**: A glm::vec3 on the curve. _description: _ ###vectype ofBezierTangent(&a, &b, &c, &d, t) _inlined_description: _ Given the four points that determine a bezier curve and an offset along the curve, return an tangent vector to a point on the curve. Currently this is not a normalized point, and will need to be normalized. **Parameters:** a The beginning point of the curve. b The first control point. c The second control point. d The end point of the curve. t an offset along the curve, normalized between 0 and 1. **Returns**: A glm::vec3 on the curve. _description: _ ###float ofClamp(value,min,max) _inlined_description: _ Clamp a value between min and max. Restricts a value to be within a specified range defined by values min and max. If the value is min <= value <= max, returns value. If the value is greater than max, return max; if the value is less than min, return min. Otherwise, return the value unchanged. ~~~~{.cpp} float val = 10; float newVal = 0; newval = ofClamp(val, 30, 40); // newval = 30 newval = ofClamp(val, 0, 5); // newval = 5 newval = ofClamp(val, 0, 20); // newval = 10 ~~~~ **Parameters:** value The number to be clamped. min The lower bound of the range. max The upper bound of the range. **Returns**: a floating point number in the range [min, max]. _description: _ ###vectype ofCurvePoint(&a, &b, &c, &d, t) _inlined_description: _ Given the four points that determine a Catmull Rom curve, return an interpolated point on the curve. **Parameters:** a The first control point. b The beginning point of the curve. c The end point of the curve. d The second control point. t an offset along the curve, normalized between 0 and 1. **Returns**: A glm::vec3 on the curve. _description: _ ###vectype ofCurveTangent(&a, &b, &c, &d, t) _inlined_description: _ Return a tangent point for an offset along a Catmull Rom curve. **Parameters:** a The first control point. b The beginning point of the curve. c The end point of the curve. d The second control point. t an offset along the curve, normalized between 0 and 1. **Returns**: A glm::vec3 on the curve. _description: _ ###float ofDegToRad(degrees) _inlined_description: _ Convert degrees to radians. Example: ~~~~{.cpp} float result = ofDegToRad(90); // The result will be PI/2. ~~~~ **Parameters:** degrees An angle in degrees. **Returns**: the angle in radians. _description: _ ###float ofDist(x1, y1, x2, y2) _inlined_description: _ Calculates the 2D distance between two points. Uses the [Pythagorean theorem](http://en.wikipedia.org/wiki/Pythagorean_theorem). **Parameters:** x1 X position of first point. y1 Y position of first point. x2 X position of second point. y2 Y position of second point. **Returns**: float Distance between points. _description: _ ###float ofDist(x1, y1, z1, x2, y2, z2) _inlined_description: _ Calculates the 3D distance between two points. Uses the [Pythagorean theorem](http://en.wikipedia.org/wiki/Pythagorean_theorem). **Parameters:** x1 X position of first point. y1 Y position of first point. z1 Z position of first point. x2 X position of second point. y2 Y position of second point. z2 Z position of second point. **Returns**: float Distance between points. _description: _ ###float ofDistSquared(x1, y1, x2, y2) _inlined_description: _ Calculates the squared 2D distance between two points. Same as ofDist() but doesn't take the square root sqrt() of the result, which is a faster operation if you need to calculate and compare multiple distances. **Parameters:** x1 X position of first point. y1 Y position of first point. x2 X position of second point. y2 Y position of second point. **Returns**: distance-squared between two points. _description: _ ###float ofDistSquared(x1, y1, z1, x2, y2, z2) _inlined_description: _ Calculates the squared 3D distance between two points. Same as ofDist() but doesn't take the square root sqrt() of the result, which is a faster operation if you need to calculate and compare multiple distances. **Parameters:** x1 X position of first point. y1 Y position of first point. z1 Z position of first point. x2 X position of second point. y2 Y position of second point. z2 Z position of second point. **Returns**: distance-squared between two points. _description: _ ###bool ofInRange(t,min,max) _inlined_description: _ Determine if a number is inside of a giv(float)(en range. **Parameters:** t The value to test. min The lower bound of the range. max The upper bound of the range. **Returns**: true if the number t is the range of [min, max]. _description: _ ###Type ofInterpolateCatmullRom(&y0, &y1, &y2, &y3, pct) _inlined_description: _ _description: _ ###Type ofInterpolateCosine(&y1, &y2, pct) _inlined_description: _ \} _description: _ ###Type ofInterpolateCubic(&y0, &y1, &y2, &y3, pct) _inlined_description: _ _description: _ ###Type ofInterpolateHermite(&y0, &y1, &y2, &y3, pct) _inlined_description: _ _description: _ ###Type ofInterpolateHermite(&y0, &y1, &y2, &y3, pct, tension, bias) _inlined_description: _ _description: _ ###typename enable_if::value, bool >::type ofIsFloatEqual(&a, &b) _inlined_description: _ Compare two floating point types for equality. From C++ FAQ: Floating point arithmetic is different from real number arithmetic. Never use `==` to compare two floating point numbers. This solution is not completely symmetric, meaning it is possible for `ofIsFloatEqual(x, y) != ofIsFloatEqual(y, x)`. From a practical standpoint, this does not usually occur when the magnitudes of x and y are significantly larger than epsilon, but your mileage may vary. **See also**: https://isocpp.org/wiki/faq/newbie#floating-point-arith **See also**: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html \tparam The floating point data type. **Parameters:** a The first floating point type variable to compare. b The second floating point type variable to compare. **Returns**: True if `std::abs(x - y) <= std::numeric_limits::epsilon() * std::abs(x)`. _description: _ ###float ofLerp(start,stop,amt) _inlined_description: _ Linearly interpolate a value within a range. Calculates a number between two numbers [start, stop] at a specific increment (amt). If we want the new number to be between start and stop numbers, amt needs to be a number between 0 and 1, inclusive. ofLerp() does not clamp the values. ~~~~{.cpp} float init = 1; float end = 2; float increment = 0.2; float result = ofLerp(init, end, increment); // result = 1.2 // Values outside 0...1 work as well. increment = 2; result = ofLerp(init, end, increment); // result = 3 ~~~~ **See also**: float ofClamp(float value, float min, float max) **Parameters:** start The lower bound of the range. stop The upper bound of the range. amt The normalized [0, 1] value within the range to return. **Returns**: A float between start and stop. _description: _ ###float ofLerpDegrees(currentAngle, targetAngle, pct) _inlined_description: _ Linearly interpolate a value between two angles in degrees. Calculates a number between two numbers [start, stop) at a specific increment (amt). This does constrain the result into a single rotation, but does not clamp the values **Parameters:** currentAngle The lower bound of the range in degrees. targetAngle The upper bound of the range in degrees. pct An amount between [0.0, 1.0] within the range to return. **Returns**: An angle in degrees between currentAngle and targetAngle. _description: _ ###float ofLerpRadians(currentAngle, targetAngle, pct) _inlined_description: _ Linearly interpolate a value between two angles in radians. Calculates a number between two numbers (start, stop) at a specific increment (amt). This does constrain the result into a single rotation, but does not clamp the values **Parameters:** currentAngle The lower bound of the range in radians. targetAngle The upper bound of the range in radians. pct An amount between [0.0, 1.0] within the range to return. **Returns**: An angle in radians between currentAngle and targetAngle. _description: _ ###bool ofLineSegmentIntersection(&line1Start, &line1End, &line2Start, &line2End, &intersection) _inlined_description: _ Determine the intersection between two lines. **Parameters:** line1Start Starting point for first line. line1End End point for first line. line2Start Starting point for second line. line2End End point for second line. intersection glm::vec3 reference in which to store the computed intersection point. **Returns**: True if the lines intersect. _description: _ ###float ofMap(value, inputMin, inputMax, outputMin, outputMax, clamp = false) _inlined_description: _ Given a value and an input range, map the value to an output range. ofMap linearly maps the given value to a new value given an input and output range. Thus if value is 50% of the way between inputMin and inputMax, the output value will be 50% of the way between outpuMin and outputMax. For an input value _outside_ of the intputMin and inputMax range, negative percentages and percentages greater than 100% will be used. For example, if the input value is 150 and the input range is 0 - 100 and the output range 0 - 1000, the output value will be 1500 or 150% of the total range. The user can avoid mapping outside of the input range by clamping the output value. Clamping is disabled by default and ensures that the output value always stays in the range [outputMin, outputMax). Example: ~~~~~{.cpp} float x = 5; float newx = 0; // 0 <= x < 10 newx = ofMap(x, 0, 10, 21, 22); // newx = 21.5 a value [21, 22). ~~~~~ **Parameters:** value The number to be mapped. inputMin The lower bound of the input range. inputMax The upper bound of the input range. outputMin The lower bound of the output range. outputMax The upper bound of the output range. clamp True if the value should be clamped to [outputMin, outputMax). \note If the absolute difference between inputMin and inputMax is less than FLT_EPSILON, outputMin will be returned to prevent divide by zero errors. **Returns**: a mapped floating point number. _description: _ ###int ofNextPow2(input) _inlined_description: _ Calculates the next larger power of 2. If the input is already a power of 2, it will return itself. Example: ~~~~{.cpp} ofNextPow2(50); // returns 64 ofNextPow2(64); // returns 64 ofNextPow2(401); // returns 512 ~~~~ **Parameters:** a The starting point for finding the next power of 2. **Returns**: value^2. _description: _ ###float ofNoise(&p) _inlined_description: _ Calculates a two dimensional Simplex Noise value between 0.0...1.0. _description: _ ###float ofNoise(&p) _inlined_description: _ Calculates a three dimensional Simplex Noise value between 0.0...1.0. _description: _ ###float ofNoise(&p) _inlined_description: _ Calculates a four dimensional Simplex Noise value between 0.0...1.0. _description: _ ###float ofNoise(x) _inlined_description: _ Calculates a one dimensional Simplex Noise value between 0.0...1.0. _description: _ ###float ofNoise(x, y) _inlined_description: _ Calculates a two dimensional Simplex Noise value between 0.0...1.0. _description: _ ###float ofNoise(x, y, z) _inlined_description: _ Calculates a three dimensional Simplex Noise value between 0.0...1.0. _description: _ ###float ofNoise(x, y, z, w) _inlined_description: _ Calculates a four dimensional Simplex Noise value between 0.0...1.0. _description: _ ###float ofNormalize(float value, float min, float max) _inlined_description: _ Given a value and an input range, map the value to be within 0 and 1. Often, you'll need to work with percentages or other methods that expect a value between 0 and 1. This function will take a minimum and maximum and then finds where within that range a value sits. If the value is outside the range, it will be mapped to 0 or 1. **Parameters:** value The number to be normalized. min The lower bound of the range. max The upper bound of the range. **Returns**: A float between 0 and 1. _description: _ ###float ofRadToDeg(radians) _inlined_description: _ Convert radians to degrees. Example: ~~~~{.cpp} float result = ofRadToDeg(PI/2); // The result will be 90. ~~~~ **Parameters:** radians An angle in radians. **Returns**: the angle in degrees. _description: _ ###float ofRandom(max) _inlined_description: _ Get a random floating point number between 0 and max. A random number in the range [0, max) will be returned. Example: ~~~~~{.cpp} // Return a random floating point number between 0 and 20. float randomNumber = ofRandom(20); ~~~~~ **Warning**: ofRandom wraps C++'s `rand()` which is not reentrant or thread safe. **Parameters:** max The maximum value of the random number. _description: _ ###float ofRandom(val0,val1) _inlined_description: _ Get a random number between two values. A random number in the range [min, max) will be returned. Example: ~~~~~{.cpp} // Return a random floating point number between -30 and 20. float randomNumber = ofRandom(-30, 20); ~~~~~ **Warning**: ofRandom wraps `rand()` which is not reentrant or thread safe. **Parameters:** val0 the minimum value of the random number. val1 The maximum value of the random number. **Returns**: A random floating point number between val0 and val1. _description: _ ###float ofRandomHeight() _inlined_description: _ Get a random floating point number between 0 and the screen height. A random number in the range [0, ofGetHeight()) will be returned. **Warning**: ofRandom wraps `rand()` which is not reentrant or thread safe. **Returns**: a random number between 0 and ofGetHeight(). _description: _ ###float ofRandomWidth() _inlined_description: _ Get a random floating point number between 0 and the screen width. A random number in the range [0, ofGetWidth()) will be returned. **Warning**: ofRandom wraps `rand()` which is not reentrant or thread safe. **Returns**: a random number between 0 and ofGetWidth(). _description: _ ###float ofRandomf() _inlined_description: _ Get a random floating point number. **Warning**: ofRandom wraps `rand()` which is not reentrant or thread safe. **Returns**: A random floating point number between -1 and 1. _description: _ ###float ofRandomuf() _inlined_description: _ Get a random unsigned floating point number. **Warning**: ofRandom wraps `rand()` which is not reentrant or thread safe. **Returns**: A random floating point number between 0 and 1. _description: _ ###void ofSeedRandom() _inlined_description: _ Seed the seeds the random number generator with a unique value. This seeds the random number generator with an acceptably random value, generated from clock time and the PID. _description: _ ###void ofSeedRandom(val) _inlined_description: _ Seed the random number generator. If the user would like to repeat the same random sequence, a known random seed can be used to initialize the random number generator during app setup. This can be useful for debugging and testing. **Parameters:** val The value with which to seed the generator. _description: _ ###int ofSign(n) _inlined_description: _ Returns the sign of a number. **Returns**: int -1 if n is negative, 1 if n is positive, and 0 is n == 0; _description: _ ###float ofSignedNoise(&p) _inlined_description: _ Calculates a two dimensional Simplex Noise value between -1.0...1.0. _description: _ ###float ofSignedNoise(&p) _inlined_description: _ Calculates a three dimensional Simplex Noise value between -1.0...1.0. _description: _ ###float ofSignedNoise(&p) _inlined_description: _ Calculates a four dimensional Simplex Noise value between -1.0...1.0. _description: _ ###float ofSignedNoise(x) _inlined_description: _ Calculates a one dimensional Simplex Noise value between -1.0...1.0. _description: _ ###float ofSignedNoise(x, y) _inlined_description: _ Calculates a two dimensional Simplex Noise value between -1.0...1.0. _description: _ ###float ofSignedNoise(x, y, z) _inlined_description: _ Calculates a three dimensional Simplex Noise value between -1.0...1.0. _description: _ ###float ofSignedNoise(x, y, z, w) _inlined_description: _ Calculates a four dimensional Simplex Noise value between -1.0...1.0. _description: _ ###float ofWrap(value, from, to) _inlined_description: _ Find a value within a given range, wrapping the value if it overflows. If a value is between from and to, return that value. If a value is NOT within that range, wrap it. Example: ~~~~{.cpp} ofWrap(5, 0, 10); // Returns 5. ofWrap(15, 0, 10); // Also returns 5. ofWrap(-5, 0, 10); // Also returns 5. ~~~~ **Parameters:** value The value to map. from The lower bound of the range. **Returns**: to The upper bound of the range. _description: _ ###float ofWrapDegrees(angle, from = -180, to = +180) _inlined_description: _ _description: _ ###float ofWrapRadians(angle, from = -PI, to = +PI) _inlined_description: _ _description: _