Esta Clase proporciona funciones y constantes matematicas de uso comun. Más...
#include <Maths.h>
Métodos públicos | |
| void | cylindricalToCartesian (float radius, float theta, float height, unsigned int axis, float &x, float &y, float &z) |
| void | cartesianToCylindrical (float x, float y, float z, float &radius, float &theta, float &height, unsigned int axis, float tolerance=EPSILON) |
| void | polarToCartesian (float radius, float theta, float &x, float &y) |
| void | cartesian_to_polar (float x, float y, float &radius, float &theta, float tolerance=EPSILON) |
Métodos públicos estáticos | |
| template<typename T > | |
| static T | lerp (const T &a, const T &b, float t) |
| template<typename T > | |
| static T | bilerp (const T &a, const T &b, const T &c, const T &d, float u, float v) |
| static void | cartesianToSpherical (float x, float y, float z, float &rho, float &phi, float &theta) |
| static void | sphericalToCartesian (float rho, float phi, float theta, float &x, float &y, float &z) |
| static bool | closeEnough (float f1, float f2) |
| static float | degreesToRadians (float degrees) |
| static float | radiansToDegrees (float radians) |
| static long | floatToLong (float f) |
| static bool | isPower2 (int x) |
| static int | nextPower2 (int x) |
| static int | nextMultipleOf (int multiple, int value) |
| static float | random (float min, float max) |
| static float | smoothstep (float a, float b, float x) |
Atributos públicos estáticos | |
| static const float | PI = 3.1415926f |
| static const float | HALF_PI = Math::PI / 2.0f |
| static const float | QUARTER_PI = Math::PI / 4.0f |
| static const float | TWO_PI = Math::PI * 2.0f |
| static const float | INV_PI = 1 / Math::PI |
| static const float | INV_TWO_PI = 1 / Math::TWO_PI |
| static const float | EPSILON = 1e-6f |
Esta Clase proporciona funciones y constantes matematicas de uso comun.
| static T Math::bilerp | ( | const T & | a, | |
| const T & | b, | |||
| const T & | c, | |||
| const T & | d, | |||
| float | u, | |||
| float | v | |||
| ) | [inline, static] |
Realiza una interpolacion bilinear. P(u,v) = e + v(f - e) donde e = a + u(b - a) f = c + u(d - c) u en rango [0,1] v en rango [0,1]
| void Math::cartesian_to_polar | ( | float | x, | |
| float | y, | |||
| float & | radius, | |||
| float & | theta, | |||
| float | tolerance = EPSILON | |||
| ) | [inline] |
Convierte coordenadas Cartesianas a polares en R2
| void Math::cartesianToCylindrical | ( | float | x, | |
| float | y, | |||
| float | z, | |||
| float & | radius, | |||
| float & | theta, | |||
| float & | height, | |||
| unsigned int | axis, | |||
| float | tolerance = EPSILON | |||
| ) | [inline] |
Convierte coordenadas Cartesianas a Cilindricas en R3, axis indica el eje del cilindro 0=x 1=y 2=z
| static void Math::cartesianToSpherical | ( | float | x, | |
| float | y, | |||
| float | z, | |||
| float & | rho, | |||
| float & | phi, | |||
| float & | theta | |||
| ) | [inline, static] |
Todos los angulos estan en radianes. rho = distancia del origen O al punto P (ej: largo de OP) phi = angulo entre OP y el plano XZ theta = angulo entre eje X y OP proyectado al plano XZ
| static bool Math::closeEnough | ( | float | f1, | |
| float | f2 | |||
| ) | [inline, static] |
Determina si los dos valores floating-point f1 y f2 son suficientemente cercanos como para considerarlos iguales.
| void Math::cylindricalToCartesian | ( | float | radius, | |
| float | theta, | |||
| float | height, | |||
| unsigned int | axis, | |||
| float & | x, | |||
| float & | y, | |||
| float & | z | |||
| ) | [inline] |
Convierte coordenadas cilindricas a Cartesianas en R3, axis indica el eje del cilindro 0=x 1=y 2=z
| static long Math::floatToLong | ( | float | f | ) | [inline, static] |
Convierte un numero floating point en un entero. Valores fraccionales son truncados segun ANSI C. 5 o 6 veces mas rapido que castear a entero.
| static T Math::lerp | ( | const T & | a, | |
| const T & | b, | |||
| float | t | |||
| ) | [inline, static] |
Realiza una interpolacion linear. P(t) = (1 - t)a + tb = a + t(b - a)
donde t en el rango [0,1]
| static int Math::nextMultipleOf | ( | int | multiple, | |
| int | value | |||
| ) | [inline, static] |
Retorna el multiplo de multiple mas cercano a value que no es menor que value.
| void Math::polarToCartesian | ( | float | radius, | |
| float | theta, | |||
| float & | x, | |||
| float & | y | |||
| ) | [inline] |
Convierte coordenadas polares a Cartesianas en R2
| static float Math::random | ( | float | min, | |
| float | max | |||
| ) | [inline, static] |
Retorna un numero al azar dentro del rango [min,max].
| static float Math::smoothstep | ( | float | a, | |
| float | b, | |||
| float | x | |||
| ) | [inline, static] |
Retorna una transicion gradual de 'x' desde 0 a 1 comenzando en 'a' y finalizando en 'b'.
Referencias: [1] http://www.rendermanacademy.com/docs/smoothstep.htm [2] http://www.brlcad.org/doxygen/d8/d33/noise_8c-source.html [3] Natalya Tatarchuk, "Efficient High-Level Shader Development", Game Developers Conference Europe, August 2003.
| static void Math::sphericalToCartesian | ( | float | rho, | |
| float | phi, | |||
| float | theta, | |||
| float & | x, | |||
| float & | y, | |||
| float & | z | |||
| ) | [inline, static] |
Todos los angulos estan en radianes. rho = distancia del origen O al punto P (ej: largo de OP) phi = angulo entre OP y el plano XZ theta = angulo entre eje X y OP proyectado al plano XZ
1.7.1