reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofMath.h File Reference
#include "ofConstants.h"
#include <cmath>
#include <glm/gtc/constants.hpp>
#include <glm/fwd.hpp>

Go to the source code of this file.

Functions

Random Numbers
float ofRandom (float max)
 Get a random floating point number between 0 and max.
 
float ofRandom (float val0, float val1)
 Get a random number between two values.
 
float ofRandomf ()
 Get a random floating point number.
 
float ofRandomuf ()
 Get a random unsigned floating point number.
 
float ofRandomWidth ()
 Get a random floating point number between 0 and the screen width.
 
float ofRandomHeight ()
 Get a random floating point number between 0 and the screen height.
 
void ofSetRandomSeed (unsigned long new_seed)
 Seed the random number generator.
 
void ofSeedRandom ()
 Seeds the random number generator with a unique value.
 
void ofSeedRandom (int val)
 Seed the random number generator.
 
Number Ranges
float ofNormalize (float value, float min, float max)
 Given a value and an input range, map the value to be within 0 and 1.
 
float ofMap (float value, float inputMin, float inputMax, float outputMin, float outputMax, bool clamp=false)
 Given a value and an input range, map the value to an output range.
 
float ofClamp (float value, float min, float max)
 Clamp a value between min and max.
 
bool ofInRange (float t, float min, float max)
 Determine if a number is inside of a giv(float)(en range.
 
float ofLerp (float start, float stop, float amt)
 Linearly interpolate a value within a range.
 
Distance
float ofDist (float x1, float y1, float x2, float y2)
 Calculates the 2D distance between two points.
 
float ofDist (float x1, float y1, float z1, float x2, float y2, float z2)
 Calculates the 3D distance between two points.
 
float ofDistSquared (float x1, float y1, float x2, float y2)
 Calculates the squared 2D distance between two points.
 
float ofDistSquared (float x1, float y1, float z1, float x2, float y2, float z2)
 Calculates the squared 3D distance between two points.
 
Angles
float ofRadToDeg (float radians)
 Convert radians to degrees.
 
float ofDegToRad (float degrees)
 Convert degrees to radians.
 
float ofLerpDegrees (float currentAngle, float targetAngle, float pct)
 Linearly interpolate a value between two angles in degrees.
 
float ofLerpRadians (float currentAngle, float targetAngle, float pct)
 Linearly interpolate a value between two angles in radians.
 
float ofAngleDifferenceDegrees (float currentAngle, float targetAngle)
 Calculates the difference between two angles in degrees.
 
float ofAngleDifferenceRadians (float currentAngle, float targetAngle)
 Calculates the difference between two angles in radians.
 
Number wrapping
float ofWrap (float value, float from, float to)
 Find a value within a given range, wrapping the value if it overflows.
 
float ofWrapRadians (float angle, float from=-glm::pi< float >(), float to=glm::pi< float >())
 
float ofWrapDegrees (float angle, float from=-180, float to=+180)
 
Noise
float ofNoise (float x)
 Calculates a one dimensional Perlin noise value between 0.0...1.0.
 
float ofNoise (float x, float y)
 Calculates a two dimensional Perlin noise value between 0.0...1.0.
 
float ofNoise (const glm::vec2 &p)
 Calculates a two dimensional Perlin noise value between 0.0...1.0.
 
float ofNoise (float x, float y, float z)
 Calculates a three dimensional Perlin noise value between 0.0...1.0.
 
float ofNoise (const glm::vec3 &p)
 Calculates a three dimensional Perlin noise value between 0.0...1.0.
 
float ofNoise (float x, float y, float z, float w)
 Calculates a four dimensional Perlin noise value between 0.0...1.0.
 
float ofNoise (const glm::vec4 &p)
 Calculates a four dimensional Perlin noise value between 0.0...1.0.
 
float ofSignedNoise (float x)
 Calculates a one dimensional Perlin noise value between -1.0...1.0.
 
float ofSignedNoise (float x, float y)
 Calculates a two dimensional Perlin noise value between -1.0...1.0.
 
float ofSignedNoise (const glm::vec2 &p)
 Calculates a two dimensional Perlin noise value between -1.0...1.0.
 
float ofSignedNoise (float x, float y, float z)
 Calculates a three dimensional Perlin noise value between -1.0...1.0.
 
float ofSignedNoise (const glm::vec3 &p)
 Calculates a three dimensional Perlin noise value between -1.0...1.0.
 
float ofSignedNoise (float x, float y, float z, float w)
 Calculates a four dimensional Perlin noise value between -1.0...1.0.
 
float ofSignedNoise (const glm::vec4 &p)
 Calculates a four dimensional Perlin noise value between -1.0...1.0.
 
Geometry
template<class vectype >
bool ofLineSegmentIntersection (const vectype &line1Start, const vectype &line1End, const vectype &line2Start, const vectype &line2End, vectype &intersection)
 Determine the intersection between two lines.
 
template<class vectype >
vectype ofBezierPoint (const vectype &a, const vectype &b, const vectype &c, const vectype &d, float t)
 Given the four points that determine a bezier curve, return an interpolated point on the curve.
 
template<class vectype >
vectype ofCurvePoint (const vectype &a, const vectype &b, const vectype &c, const vectype &d, float t)
 Given the four points that determine a Catmull Rom curve, return an interpolated point on the curve.
 
template<class vectype >
vectype ofBezierTangent (const vectype &a, const vectype &b, const vectype &c, const vectype &d, float t)
 
template<class vectype >
vectype ofCurveTangent (const vectype &a, const vectype &b, const vectype &c, const vectype &d, float t)
 Return a tangent point for an offset along a Catmull Rom curve.
 
template<typename Type >
Type ofInterpolateCosine (const Type &y1, const Type &y2, float pct)
 
template<typename Type >
Type ofInterpolateCubic (const Type &y0, const Type &y1, const Type &y2, const Type &y3, float pct)
 
template<typename Type >
Type ofInterpolateCatmullRom (const Type &y0, const Type &y1, const Type &y2, const Type &y3, float pct)
 
template<typename Type >
Type ofInterpolateHermite (const Type &y0, const Type &y1, const Type &y2, const Type &y3, float pct)
 
template<typename Type >
Type ofInterpolateHermite (const Type &y0, const Type &y1, const Type &y2, const Type &y3, float pct, float tension, float bias)
 
Others
int ofNextPow2 (int a)
 Calculates the next larger power of 2.
 
int ofSign (float n)
 Returns the sign of a number.
 
template<typename Type >
std::enable_if< std::is_floating_point< Type >::value, bool >::type ofIsFloatEqual (const Type &a, const Type &b)
 Compare two floating point types for equality.
 

Detailed Description

ofMath provides a collection of mathematical utilities and functions.

Warning
Many ofRandom-style functions wrap rand() which is not reentrant or thread safe. To generate random numbers simultaneously in multiple threads, consider using c++11 uniform_real_distribution.
See also
http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution

Function Documentation

◆ ofAngleDifferenceDegrees()

float ofAngleDifferenceDegrees ( float  currentAngle,
float  targetAngle 
)

Calculates the difference between two angles in degrees.

This will calculate the actual difference, taking into account multiple revolutions. For example:

ofAngleDifferenceDegrees(0, 90); // Returns 90.
ofAngleDifferenceDegrees(0, 450); // Also returns 90.
float ofAngleDifferenceDegrees(float currentAngle, float targetAngle)
Calculates the difference between two angles in degrees.
Definition ofMath.cpp:253
Parameters
currentAngleThe current angle in degrees.
targetAnglethe angle to be compared to in degrees.
Returns
The difference between two angles in degrees.

◆ ofAngleDifferenceRadians()

float ofAngleDifferenceRadians ( float  currentAngle,
float  targetAngle 
)

Calculates the difference between two angles in radians.

This will calculate the actual difference, taking into account multiple revolutions. For example:

ofAngleDifferenceRadians(0, PI); // Returns -PI.
ofAngleDifferenceRadians(0, 3*PI); // Also returns -PI.
float ofAngleDifferenceRadians(float currentAngle, float targetAngle)
Calculates the difference between two angles in radians.
Definition ofMath.cpp:258
#define PI
Definition ofMathConstants.h:21
Parameters
currentAngleThe current angle in radians.
targetAnglethe angle to be compared to in radians.
Returns
The difference between two angles in radians.

◆ ofBezierPoint()

template<class vectype >
vectype ofBezierPoint ( const vectype &  a,
const vectype &  b,
const vectype &  c,
const vectype &  d,
float  t 
)

Given the four points that determine a bezier curve, return an interpolated point on the curve.

Parameters
aThe beginning point of the curve.
bThe first control point.
cThe second control point.
dThe end point of the curve.
tan offset along the curve, normalized between 0 and 1.
Returns
A glm::vec3 on the curve.

◆ ofBezierTangent()

template<class vectype >
vectype ofBezierTangent ( const vectype &  a,
const vectype &  b,
const vectype &  c,
const vectype &  d,
float  t 
)

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
aThe beginning point of the curve.
bThe first control point.
cThe second control point.
dThe end point of the curve.
tan offset along the curve, normalized between 0 and 1.
Returns
A glm::vec3 on the curve.

◆ ofClamp()

float ofClamp ( float  value,
float  min,
float  max 
)

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.

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
float ofClamp(float value, float min, float max)
Clamp a value between min and max.
Definition ofMath.cpp:120
Parameters
valueThe number to be clamped.
minThe lower bound of the range.
maxThe upper bound of the range.
Returns
a floating point number in the range [min, max].

◆ ofCurvePoint()

template<class vectype >
vectype ofCurvePoint ( const vectype &  a,
const vectype &  b,
const vectype &  c,
const vectype &  d,
float  t 
)

Given the four points that determine a Catmull Rom curve, return an interpolated point on the curve.

Parameters
aThe first control point.
bThe beginning point of the curve.
cThe end point of the curve.
dThe second control point.
tan offset along the curve, normalized between 0 and 1.
Returns
A glm::vec3 on the curve.

◆ ofCurveTangent()

template<class vectype >
vectype ofCurveTangent ( const vectype &  a,
const vectype &  b,
const vectype &  c,
const vectype &  d,
float  t 
)

Return a tangent point for an offset along a Catmull Rom curve.

Parameters
aThe first control point.
bThe beginning point of the curve.
cThe end point of the curve.
dThe second control point.
tan offset along the curve, normalized between 0 and 1.
Returns
A glm::vec3 on the curve.

◆ ofDegToRad()

float ofDegToRad ( float  degrees)

Convert degrees to radians.

Example:

float result = ofDegToRad(90); // The result will be PI/2.
float ofDegToRad(float degrees)
Convert degrees to radians.
Definition ofMath.cpp:142
Parameters
degreesAn angle in degrees.
Returns
the angle in radians.

◆ ofDist() [1/2]

float ofDist ( float  x1,
float  y1,
float  x2,
float  y2 
)

Calculates the 2D distance between two points.

Uses the Pythagorean theorem.

Parameters
x1X position of first point.
y1Y position of first point.
x2X position of second point.
y2Y position of second point.
Returns
float Distance between points.

◆ ofDist() [2/2]

float ofDist ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2 
)

Calculates the 3D distance between two points.

Uses the Pythagorean theorem.

Parameters
x1X position of first point.
y1Y position of first point.
z1Z position of first point.
x2X position of second point.
y2Y position of second point.
z2Z position of second point.
Returns
float Distance between points.

◆ ofDistSquared() [1/2]

float ofDistSquared ( float  x1,
float  y1,
float  x2,
float  y2 
)

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
x1X position of first point.
y1Y position of first point.
x2X position of second point.
y2Y position of second point.
Returns
distance-squared between two points.

◆ ofDistSquared() [2/2]

float ofDistSquared ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2 
)

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
x1X position of first point.
y1Y position of first point.
z1Z position of first point.
x2X position of second point.
y2Y position of second point.
z2Z position of second point.
Returns
distance-squared between two points.

◆ ofInRange()

bool ofInRange ( float  t,
float  min,
float  max 
)

Determine if a number is inside of a giv(float)(en range.

Parameters
tThe value to test.
minThe lower bound of the range.
maxThe upper bound of the range.
Returns
true if the number t is the range of [min, max].

◆ ofInterpolateCatmullRom()

template<typename Type >
Type ofInterpolateCatmullRom ( const Type &  y0,
const Type &  y1,
const Type &  y2,
const Type &  y3,
float  pct 
)

◆ ofInterpolateCosine()

template<typename Type >
Type ofInterpolateCosine ( const Type &  y1,
const Type &  y2,
float  pct 
)

◆ ofInterpolateCubic()

template<typename Type >
Type ofInterpolateCubic ( const Type &  y0,
const Type &  y1,
const Type &  y2,
const Type &  y3,
float  pct 
)

◆ ofInterpolateHermite() [1/2]

template<typename Type >
Type ofInterpolateHermite ( const Type &  y0,
const Type &  y1,
const Type &  y2,
const Type &  y3,
float  pct 
)
inline

◆ ofInterpolateHermite() [2/2]

template<typename Type >
Type ofInterpolateHermite ( const Type &  y0,
const Type &  y1,
const Type &  y2,
const Type &  y3,
float  pct,
float  tension,
float  bias 
)

◆ ofIsFloatEqual()

template<typename Type >
std::enable_if< std::is_floating_point< Type >::value, bool >::type ofIsFloatEqual ( const Type &  a,
const Type &  b 
)

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
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
Template Parameters
Thefloating point data type.
Parameters
aThe first floating point type variable to compare.
bThe second floating point type variable to compare.
Returns
True if std::abs(x - y) <= std::numeric_limits<Type>::epsilon() * std::abs(x).

◆ ofLerp()

float ofLerp ( float  start,
float  stop,
float  amt 
)

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.

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
float ofLerp(float start, float stop, float amt)
Linearly interpolate a value within a range.
Definition ofMath.cpp:147
See also
float ofClamp(float value, float min, float max)
Parameters
startThe lower bound of the range.
stopThe upper bound of the range.
amtThe normalized [0, 1] value within the range to return.
Returns
A float between start and stop.

◆ ofLerpDegrees()

float ofLerpDegrees ( float  currentAngle,
float  targetAngle,
float  pct 
)

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
currentAngleThe lower bound of the range in degrees.
targetAngleThe upper bound of the range in degrees.
pctAn amount between [0.0, 1.0] within the range to return.
Returns
An angle in degrees between currentAngle and targetAngle.

◆ ofLerpRadians()

float ofLerpRadians ( float  currentAngle,
float  targetAngle,
float  pct 
)

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
currentAngleThe lower bound of the range in radians.
targetAngleThe upper bound of the range in radians.
pctAn amount between [0.0, 1.0] within the range to return.
Returns
An angle in radians between currentAngle and targetAngle.

◆ ofLineSegmentIntersection()

template<class vectype >
bool ofLineSegmentIntersection ( const vectype &  line1Start,
const vectype &  line1End,
const vectype &  line2Start,
const vectype &  line2End,
vectype &  intersection 
)

Determine the intersection between two lines.

Parameters
line1StartStarting point for first line.
line1EndEnd point for first line.
line2StartStarting point for second line.
line2EndEnd point for second line.
intersectionglm::vec3 reference in which to store the computed intersection point.
Returns
True if the lines intersect.

◆ ofMap()

float ofMap ( float  value,
float  inputMin,
float  inputMax,
float  outputMin,
float  outputMax,
bool  clamp = false 
)

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:

float x = 5;
float newx = 0;
// 0 <= x < 10
newx = ofMap(x, 0, 10, 21, 22); // newx = 21.5 a value [21, 22).
float ofMap(float value, float inputMin, float inputMax, float outputMin, float outputMax, bool clamp)
Given a value and an input range, map the value to an output range.
Definition ofMath.cpp:78
Parameters
valueThe number to be mapped.
inputMinThe lower bound of the input range.
inputMaxThe upper bound of the input range.
outputMinThe lower bound of the output range.
outputMaxThe upper bound of the output range.
clampTrue if the value should be clamped to [outputMin, outputMax).
Note
If the absolute difference between inputMin and inputMax is less than std::numeric_limits<float>::epsilon(), outputMin will be returned to prevent divide by zero errors.
Returns
a mapped floating point number.

◆ ofNextPow2()

int ofNextPow2 ( int  a)

Calculates the next larger power of 2.

If the input is already a power of 2, it will return itself.

Example:

ofNextPow2(50); // returns 64
ofNextPow2(64); // returns 64
ofNextPow2(401); // returns 512
int ofNextPow2(int a)
Calculates the next larger power of 2.
Definition ofMath.cpp:11
Parameters
aThe starting point for finding the next power of 2.
Returns
value^2.

◆ ofNoise() [1/7]

float ofNoise ( const glm::vec2 &  p)

Calculates a two dimensional Perlin noise value between 0.0...1.0.

◆ ofNoise() [2/7]

float ofNoise ( const glm::vec3 &  p)

Calculates a three dimensional Perlin noise value between 0.0...1.0.

◆ ofNoise() [3/7]

float ofNoise ( const glm::vec4 &  p)

Calculates a four dimensional Perlin noise value between 0.0...1.0.

◆ ofNoise() [4/7]

float ofNoise ( float  x)

Calculates a one dimensional Perlin noise value between 0.0...1.0.

◆ ofNoise() [5/7]

float ofNoise ( float  x,
float  y 
)

Calculates a two dimensional Perlin noise value between 0.0...1.0.

◆ ofNoise() [6/7]

float ofNoise ( float  x,
float  y,
float  z 
)

Calculates a three dimensional Perlin noise value between 0.0...1.0.

◆ ofNoise() [7/7]

float ofNoise ( float  x,
float  y,
float  z,
float  w 
)

Calculates a four dimensional Perlin noise value between 0.0...1.0.

◆ ofNormalize()

float ofNormalize ( float  value,
float  min,
float  max 
)

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
valueThe number to be normalized.
minThe lower bound of the range.
maxThe upper bound of the range.
Returns
A float between 0 and 1.

◆ ofRadToDeg()

float ofRadToDeg ( float  radians)

Convert radians to degrees.

Example:

float result = ofRadToDeg(PI/2); // The result will be 90.
float ofRadToDeg(float radians)
Convert radians to degrees.
Definition ofMath.cpp:137
Parameters
radiansAn angle in radians.
Returns
the angle in degrees.

◆ ofRandom() [1/2]

float ofRandom ( float  max)

Get a random floating point number between 0 and max.

A random number in the range [0, max) will be returned.

Example:

// Return a random floating point number between 0 and 20.
float randomNumber = ofRandom(20);
float ofRandom(float max)
Get a random floating point number between 0 and max.
Definition ofMath.cpp:47
Warning
ofRandom wraps C++'s rand() which is not reentrant or thread safe.
Parameters
maxThe maximum value of the random number.

◆ ofRandom() [2/2]

float ofRandom ( float  val0,
float  val1 
)

Get a random number between two values.

A random number in the range [min, max) will be returned.

Example:

// 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
val0the minimum value of the random number.
val1The maximum value of the random number.
Returns
A random floating point number between val0 and val1.

◆ ofRandomf()

float ofRandomf ( )

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.

◆ ofRandomHeight()

float ofRandomHeight ( )

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().
a random number between 0 and the height of the window.

◆ ofRandomuf()

float ofRandomuf ( )

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.

◆ ofRandomWidth()

float ofRandomWidth ( )

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().
a random number between 0 and the width of the window.

◆ ofSeedRandom() [1/2]

void ofSeedRandom ( )

Seeds the random number generator with a unique value.

This seeds the old-school srand-based random number generator with an acceptably random value, generated from clock time and the PID.

◆ ofSeedRandom() [2/2]

void ofSeedRandom ( int  val)

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
valThe value with which to seed the generator.

◆ ofSetRandomSeed()

void ofSetRandomSeed ( unsigned long  new_seed)

Seed the random number generator.

This passes a seed value to the random engine; see of::random::Engine for details

Parameters
valThe value with which to seed the generator.

◆ ofSign()

int ofSign ( float  n)

Returns the sign of a number.

Returns
int -1 if n is negative, 1 if n is positive, and 0 is n == 0;

◆ ofSignedNoise() [1/7]

float ofSignedNoise ( const glm::vec2 &  p)

Calculates a two dimensional Perlin noise value between -1.0...1.0.

◆ ofSignedNoise() [2/7]

float ofSignedNoise ( const glm::vec3 &  p)

Calculates a three dimensional Perlin noise value between -1.0...1.0.

◆ ofSignedNoise() [3/7]

float ofSignedNoise ( const glm::vec4 &  p)

Calculates a four dimensional Perlin noise value between -1.0...1.0.

◆ ofSignedNoise() [4/7]

float ofSignedNoise ( float  x)

Calculates a one dimensional Perlin noise value between -1.0...1.0.

◆ ofSignedNoise() [5/7]

float ofSignedNoise ( float  x,
float  y 
)

Calculates a two dimensional Perlin noise value between -1.0...1.0.

◆ ofSignedNoise() [6/7]

float ofSignedNoise ( float  x,
float  y,
float  z 
)

Calculates a three dimensional Perlin noise value between -1.0...1.0.

◆ ofSignedNoise() [7/7]

float ofSignedNoise ( float  x,
float  y,
float  z,
float  w 
)

Calculates a four dimensional Perlin noise value between -1.0...1.0.

◆ ofWrap()

float ofWrap ( float  value,
float  from,
float  to 
)

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:

ofWrap(5, 0, 10); // Returns 5.
ofWrap(15, 0, 10); // Also returns 5.
ofWrap(-5, 0, 10); // Also returns 5.
float ofWrap(float value, float from, float to)
Find a value within a given range, wrapping the value if it overflows.
Definition ofMath.cpp:151
Parameters
valueThe value to map.
fromThe lower bound of the range.
Returns
to The upper bound of the range.

◆ ofWrapDegrees()

float ofWrapDegrees ( float  angle,
float  from = -180,
float  to = +180 
)

◆ ofWrapRadians()

float ofWrapRadians ( float  angle,
float  from = -glm::pi< float >(),
float  to = glm::pi< float >() 
)