This namespace contains all mathematical basic functions such as sine, cosine, distance calculations etc. More...
Namespaces | |
namespace | CollisionLibrary |
Here you will find each function for collision detection, distance computation and intersection tests. | |
namespace | InterpolatorManager |
namespace | Randomizer |
Namepsace for all random-generation functions. | |
namespace | Rasterizer |
Namespace for rasterization templates. | |
namespace | TriangleCutter |
Classes | |
class | Interpolator |
class | FunctionalInterpolator |
class | UInt128 |
class | MD5CheckSum |
class | RadianDegreeAngle |
class | Degree |
Degree class. An instance of this class will always store a value in the range [0.0 .. 360.0). More... | |
class | Radian |
Radian class. An instance of this class will always store a value in the range [0.0 .. 2*pi). More... | |
class | RasterizerVertex |
struct | SSplinePolynom |
class | Spline |
Multi-dimensional spline class. More... | |
struct | STriangleCut |
Typedefs | |
typedef FunctionalInterpolator < f32, f32,&Lerp > | LinearInterpolator |
typedef FunctionalInterpolator < f32, f32,&LerpParabolic > | ParabolicInterpolator |
typedef FunctionalInterpolator < f32, f32,&LerpSin > | SinInterpolator |
typedef boost::function< void(s32 x, s32 y, void *UserData) | RenderPixelCallback ) |
Callback function interface for rasterization without vertices. | |
typedef Spline< dim::point2df, f32, 2 > | Spline2D |
typedef Spline< dim::vector3df, f32, 3 > | Spline3D |
Enumerations | |
enum | ETriangleCutResults { TRIANGLECUT_NONE, TRIANGLECUT_QUAD_AND_TRIANGLE, TRIANGLECUT_TWO_TRIANGLES } |
Possible results of a triangle clip. More... | |
Functions | |
SP_EXPORT void | getVertexInterpolation (const dim::triangle3df &Triangle, const dim::vector3df &Pos, f32 &Vert, f32 &Horz) |
SP_EXPORT dim::matrix4f | getTangentSpace (const dim::vector3df PosA, const dim::vector3df PosB, const dim::vector3df PosC, const dim::point2df MapA, const dim::point2df MapB, const dim::point2df MapC, dim::vector3df &Tangent, dim::vector3df &Binormal, dim::vector3df &Normal) |
template<typename T > | |
T | getDistance (const dim::point2d< T > &PosA, const dim::point2d< T > &PosB) |
Returns the distance between the two given 2D points. | |
template<typename T > | |
T | getDistance (const dim::vector3d< T > &PosA, const dim::vector3d< T > &PosB) |
Returns the distance between the two given 3D points. | |
template<typename T > | |
T | getDistanceSq (const dim::point2d< T > &PosA, const dim::point2d< T > &PosB) |
template<typename T > | |
T | getDistanceSq (const dim::vector3d< T > &PosA, const dim::vector3d< T > &PosB) |
template<typename T > | |
T | getAngle (const dim::point2d< T > &A, const dim::point2d< T > &B) |
template<typename T > | |
T | getAngle (const dim::point2d< T > &A, const dim::point2d< T > &B, const T &OffsetAngle) |
template<typename T > | |
dim::vector3d< T > | getNormalVectorSq (const dim::vector3d< T > &PosA, const dim::vector3d< T > &PosB, const dim::vector3d< T > &PosC) |
Returns normal vector computed by the three specified coordinates. | |
template<typename T > | |
dim::vector3d< T > | getNormalVector (const dim::vector3d< T > &PosA, const dim::vector3d< T > &PosB, const dim::vector3d< T > &PosC) |
Returns normalized normal vector computed by the three specified coordinates. | |
template<typename T > | |
dim::vector3d< T > | getBarycentricCoord (const dim::triangle3d< T > &Triangle, const dim::vector3d< T > &Point) |
template<typename T > | |
void | sortContainerConst (std::vector< T > &ObjectList, bool(*lpFuncCmp)(const T &obj1, const T &obj2)) |
template<typename T > | |
void | sortContainer (std::vector< T > &ObjectList, bool(*lpFuncCmp)(T &obj1, T &obj2)) |
template<class T > | |
T | getVertexInterpolation (const T &VertexA, const T &VertexB, const T &VertexC, const f32 Vert, const f32 Horz) |
dim::vector4df | Convert (const video::color &Color) |
Returns color in form of a 4D vector. The color components R, G, B, and A are transformed to the range [0.0, 1.0]. | |
video::color | Convert (const dim::vector4df &Color) |
Returns color in typical form. The color components R, G, B, and A are transformed to the range [0, 255]. | |
template<typename T > | |
T | Abs (const T &Value) |
Returns the absolute value of the given parameter (5 -> 5 and -5 -> 5). | |
template<typename T > | |
T | Max (const T &A, const T &B) |
Returns the largest value of the specified variables. | |
template<typename T > | |
T | Min (const T &A, const T &B) |
Returns the smallest value of the specified variables. | |
template<typename T > | |
T | Max (const T &A, const T &B, const T &C) |
Returns the largest value of the specified variables. | |
template<typename T > | |
T | Min (const T &A, const T &B, const T &C) |
Returns the smallest value of the specified variables. | |
template<typename T > | |
void | Increase (T &Value, const T &PotNewValue) |
Increase the given value if the potentially new value is greater. | |
template<typename T > | |
void | Decrease (T &Value, const T &PotNewValue) |
Decrease the given value if the potentially new value is smaller. | |
template<typename T > | |
T | MinMax (const T &Value, const T &Min, const T &Max) |
Returns the input value if it is inside the range "Min" and "Max. Otherwise the clamped range. | |
template<typename T > | |
void | Clamp (T &Value, const T &Min, const T &Max) |
Clamps the variable "Value" to the range "Min" and "Max". | |
template<typename T > | |
void | Swap (T &A, T &B) |
Exchanges (or rather swaps) the content of the specified variables A and B. | |
template<typename T > | |
T | Sgn (const T &Value) |
Returns the signed value. Resulting values can only be 1, -1 or 0. | |
template<typename T > | |
T | Round (const T &Value, s32 Precision) |
Returns the rounded value to the specified precision. | |
template<typename T > | |
T | Pow2 (const T &Value) |
Returns the square of the specified value (Value * Value). | |
template<typename T > | |
T | Sin (const T &Value) |
Returns the sine of the specified value as degree. | |
template<typename T > | |
T | Cos (const T &Value) |
Returns the cosine of the specified value as degree. | |
template<typename T > | |
T | Tan (const T &Value) |
Returns the tangent of the specified value as degree. | |
template<typename T > | |
T | ASin (const T &Value) |
Returns the arcus sine of the specified value as degree. | |
template<typename T > | |
T | ACos (const T &Value) |
Returns arcus cosine of the specified value as degree. | |
template<typename T > | |
T | ATan (const T &Value) |
Returns arcus tangent of the specified value as degree. | |
template<typename T > | |
T | Log (const T &Value, const T &Base=T(10)) |
Returns the logarithm with the specified base. | |
template<typename T , typename I > | |
void | Lerp (T &Result, const T &From, const T &To, const I &Factor) |
template<typename T , typename I > | |
T | Lerp (const T &From, const T &To, const I &Factor) |
Overloaded function. For more information read the documentation of the first variant of this function. | |
template<typename T , typename I > | |
T | LerpParabolic (const T &From, const T &To, const I &Factor) |
Parabolic interpolation. This is equivalent to "Lerp(From, To, Factor*Factor)". | |
template<typename T , typename I > | |
T | LerpSin (const T &From, const T &To, const I &Factor) |
Sine interpolation. This is equivalent to "Lerp(From, To, Sin(Factor*90))". | |
s32 | Round (f32 Value) |
Rounds the float value to the nearest integer value (e.g. 3.4 to 3 and 3.5 to 4). | |
s32 | RoundPow2 (s32 Value) |
Rounds the given value to the nearest power of two value (e.g. 34 to 32 and 120 to 128). | |
bool | Equal (f32 A, f32 B, f32 Tolerance=ROUNDING_ERROR) |
Returns true if A and B are equal with the specified tolerance. | |
bool | Equal (s32 A, s32 B, s32 Tolerance=0) |
bool | getBitR2L (u32 Integer, s32 Pos) |
Returns the bit inside the specified integer at the specified position (right to left). | |
void | setBitR2L (u32 &Integer, s32 Pos, bool Enable) |
Sets the bit inside the specified integer at the specified position (right to left). | |
bool | getBitL2R (u32 Integer, s32 Pos) |
Returns the bit inside the specified integer at the specified position (left to right). | |
void | setBitL2R (u32 &Integer, s32 Pos, bool Enable) |
Sets the bit inside the specified integer at the specified position (left to right). | |
bool | getBitR2L (u8 Integer, s32 Pos) |
Returns the bit inside the specified integer at the specified position (right to left). | |
void | setBitR2L (u8 &Integer, s32 Pos, bool Enable) |
Sets the bit inside the specified integer at the specified position (right to left). | |
bool | getBitL2R (u8 Integer, s32 Pos) |
Returns the bit inside the specified integer at the specified position (left to right). | |
void | setBitL2R (u8 &Integer, s32 Pos, bool Enable) |
Sets the bit inside the specified integer at the specified position (left to right). | |
template<typename T > | |
T | getTriangleArea2D (const T &x1, const T &y1, const T &x2, const T &y2, const T &x3, const T &y3) |
template<typename T > | |
T | getBezierValue (const f32 t, const T &Pos1, const T &Pos2, const T &Radial1, const T &Radial2) |
Returns a bezier value used for bezier curves. | |
template<typename T > | |
T | getBernsteinValue (const f32 t, const T Points[4]) |
Returns a bernstein value used for bezier patch generation. | |
template<typename T > | |
T | getGaussianValue (const T &X, const T &Mean, const T &StdDeviation) |
Returns a gaussian value used for gaussian blur. | |
template<typename T > | |
T | getHaltonSequence (s32 Index, s32 Base) |
template<typename T > | |
T | ModularPow (T Base, T Exp, const T &Modulus) |
Variables | |
const f32 | DEG = PI / 180.0f |
const f32 | RAD = 180.0f / PI |
const f64 | DEG64 = PI64 / 180.0 |
const f64 | RAD64 = 180.0 / PI64 |
const f64 | SQRT2 = sqrt(2.0) |
const f32 | SQRT2F = sqrtf(2.0f) |
const f64 | STDASPECT = 4.0 / 3.0 |
This namespace contains all mathematical basic functions such as sine, cosine, distance calculations etc.
typedef FunctionalInterpolator<f32, f32, &Lerp> sp::math::LinearInterpolator |
typedef FunctionalInterpolator<f32, f32, &LerpParabolic> sp::math::ParabolicInterpolator |
typedef boost::function<void (s32 x, s32 y, void* UserData) sp::math::RenderPixelCallback) |
Callback function interface for rasterization without vertices.
typedef FunctionalInterpolator<f32, f32, &LerpSin> sp::math::SinInterpolator |
typedef Spline<dim::point2df, f32, 2> sp::math::Spline2D |
typedef Spline<dim::vector3df, f32, 3> sp::math::Spline3D |
T sp::math::Abs | ( | const T & | Value | ) | [inline] |
Returns the absolute value of the given parameter (5 -> 5 and -5 -> 5).
T sp::math::ACos | ( | const T & | Value | ) | [inline] |
Returns arcus cosine of the specified value as degree.
T sp::math::ASin | ( | const T & | Value | ) | [inline] |
Returns the arcus sine of the specified value as degree.
T sp::math::ATan | ( | const T & | Value | ) | [inline] |
Returns arcus tangent of the specified value as degree.
void sp::math::Clamp | ( | T & | Value, | |
const T & | Min, | |||
const T & | Max | |||
) | [inline] |
Clamps the variable "Value" to the range "Min" and "Max".
dim::vector4df sp::math::Convert | ( | const video::color & | Color | ) | [inline] |
Returns color in form of a 4D vector. The color components R, G, B, and A are transformed to the range [0.0, 1.0].
video::color sp::math::Convert | ( | const dim::vector4df & | Color | ) | [inline] |
Returns color in typical form. The color components R, G, B, and A are transformed to the range [0, 255].
T sp::math::Cos | ( | const T & | Value | ) | [inline] |
Returns the cosine of the specified value as degree.
void sp::math::Decrease | ( | T & | Value, | |
const T & | PotNewValue | |||
) | [inline] |
Decrease the given value if the potentially new value is smaller.
bool sp::math::Equal | ( | f32 | A, | |
f32 | B, | |||
f32 | Tolerance = ROUNDING_ERROR | |||
) | [inline] |
Returns true if A and B are equal with the specified tolerance.
bool sp::math::Equal | ( | s32 | A, | |
s32 | B, | |||
s32 | Tolerance = 0 | |||
) | [inline] |
Returns true if A and B are equal. The tolerance factor is only used to have the same interface like the floating-point version of this function.
T sp::math::getAngle | ( | const dim::point2d< T > & | A, | |
const dim::point2d< T > & | B, | |||
const T & | OffsetAngle | |||
) |
Returns the angle between the two given 2D points to the offset angle. This is in the range [-180.0 .. 180.0].
T sp::math::getAngle | ( | const dim::point2d< T > & | A, | |
const dim::point2d< T > & | B | |||
) |
Returns the angle between the two given 2D points.
[in] | A | Specifies the first 2D point. |
[in] | B | Specifies the second 2D point. |
dim::vector3d<T> sp::math::getBarycentricCoord | ( | const dim::triangle3d< T > & | Triangle, | |
const dim::vector3d< T > & | Point | |||
) |
Returns the barycentric coordinate given by the cartesian point respectively to the given triangle.
[in] | Triangle | Specifies the 3D triangle. |
[in] | Point | Specifies the cartesian point. This point must lie onto the triangle. |
T sp::math::getBernsteinValue | ( | const f32 | t, | |
const T | Points[4] | |||
) |
Returns a bernstein value used for bezier patch generation.
T sp::math::getBezierValue | ( | const f32 | t, | |
const T & | Pos1, | |||
const T & | Pos2, | |||
const T & | Radial1, | |||
const T & | Radial2 | |||
) |
Returns a bezier value used for bezier curves.
bool sp::math::getBitL2R | ( | u32 | Integer, | |
s32 | Pos | |||
) | [inline] |
Returns the bit inside the specified integer at the specified position (left to right).
bool sp::math::getBitL2R | ( | u8 | Integer, | |
s32 | Pos | |||
) | [inline] |
Returns the bit inside the specified integer at the specified position (left to right).
bool sp::math::getBitR2L | ( | u32 | Integer, | |
s32 | Pos | |||
) | [inline] |
Returns the bit inside the specified integer at the specified position (right to left).
bool sp::math::getBitR2L | ( | u8 | Integer, | |
s32 | Pos | |||
) | [inline] |
Returns the bit inside the specified integer at the specified position (right to left).
T sp::math::getDistance | ( | const dim::vector3d< T > & | PosA, | |
const dim::vector3d< T > & | PosB | |||
) | [inline] |
Returns the distance between the two given 3D points.
T sp::math::getDistance | ( | const dim::point2d< T > & | PosA, | |
const dim::point2d< T > & | PosB | |||
) | [inline] |
Returns the distance between the two given 2D points.
T sp::math::getDistanceSq | ( | const dim::point2d< T > & | PosA, | |
const dim::point2d< T > & | PosB | |||
) | [inline] |
T sp::math::getDistanceSq | ( | const dim::vector3d< T > & | PosA, | |
const dim::vector3d< T > & | PosB | |||
) | [inline] |
T sp::math::getGaussianValue | ( | const T & | X, | |
const T & | Mean, | |||
const T & | StdDeviation | |||
) |
Returns a gaussian value used for gaussian blur.
T sp::math::getHaltonSequence | ( | s32 | Index, | |
s32 | Base | |||
) |
Returns the halton sequence for the given input and base. This is used for quasi-random values. For more details take a look at: http://orion.math.iastate.edu/reu/2001/voronoi/halton_sequence.html.
[in] | Index | Specifies the sequence index. |
[in] | Base | Specifies the sequence base. This has to be a prime number! Usually beginning with 2, 3, etc. |
dim::vector3d<T> sp::math::getNormalVector | ( | const dim::vector3d< T > & | PosA, | |
const dim::vector3d< T > & | PosB, | |||
const dim::vector3d< T > & | PosC | |||
) | [inline] |
Returns normalized normal vector computed by the three specified coordinates.
dim::vector3d<T> sp::math::getNormalVectorSq | ( | const dim::vector3d< T > & | PosA, | |
const dim::vector3d< T > & | PosB, | |||
const dim::vector3d< T > & | PosC | |||
) | [inline] |
Returns normal vector computed by the three specified coordinates.
SP_EXPORT dim::matrix4f sp::math::getTangentSpace | ( | const dim::vector3df | PosA, | |
const dim::vector3df | PosB, | |||
const dim::vector3df | PosC, | |||
const dim::point2df | MapA, | |||
const dim::point2df | MapB, | |||
const dim::point2df | MapC, | |||
dim::vector3df & | Tangent, | |||
dim::vector3df & | Binormal, | |||
dim::vector3df & | Normal | |||
) |
T sp::math::getTriangleArea2D | ( | const T & | x1, | |
const T & | y1, | |||
const T & | x2, | |||
const T & | y2, | |||
const T & | x3, | |||
const T & | y3 | |||
) | [inline] |
Returns the 2D triangle area.
SP_EXPORT void sp::math::getVertexInterpolation | ( | const dim::triangle3df & | Triangle, | |
const dim::vector3df & | Pos, | |||
f32 & | Vert, | |||
f32 & | Horz | |||
) |
T sp::math::getVertexInterpolation | ( | const T & | VertexA, | |
const T & | VertexB, | |||
const T & | VertexC, | |||
const f32 | Vert, | |||
const f32 | Horz | |||
) |
void sp::math::Increase | ( | T & | Value, | |
const T & | PotNewValue | |||
) | [inline] |
Increase the given value if the potentially new value is greater.
void sp::math::Lerp | ( | T & | Result, | |
const T & | From, | |||
const T & | To, | |||
const I & | Factor | |||
) | [inline] |
Returns a linear-interpolation ('lerp') between the two given points ('From' and 'To').
[out] | Result | Specifies the resulting output point. |
[in] | From | Specifies the start point. |
[in] | To | Specifies the end point. |
[in] | Factor | Specifies the interpolation factor. This should be in the range [0.0 .. 1.0]. |
T | Specifies the type of the points (e.g. float, dim::point2df, dim::vector3df etc.). | |
I | Specifies the interpolation data type. This should be a float or a double. |
T sp::math::Lerp | ( | const T & | From, | |
const T & | To, | |||
const I & | Factor | |||
) | [inline] |
Overloaded function. For more information read the documentation of the first variant of this function.
T sp::math::LerpParabolic | ( | const T & | From, | |
const T & | To, | |||
const I & | Factor | |||
) | [inline] |
Parabolic interpolation. This is equivalent to "Lerp(From, To, Factor*Factor)".
T sp::math::LerpSin | ( | const T & | From, | |
const T & | To, | |||
const I & | Factor | |||
) | [inline] |
Sine interpolation. This is equivalent to "Lerp(From, To, Sin(Factor*90))".
T sp::math::Log | ( | const T & | Value, | |
const T & | Base = T(10) | |||
) | [inline] |
Returns the logarithm with the specified base.
T sp::math::Max | ( | const T & | A, | |
const T & | B | |||
) | [inline] |
Returns the largest value of the specified variables.
T sp::math::Max | ( | const T & | A, | |
const T & | B, | |||
const T & | C | |||
) | [inline] |
Returns the largest value of the specified variables.
T sp::math::Min | ( | const T & | A, | |
const T & | B, | |||
const T & | C | |||
) | [inline] |
Returns the smallest value of the specified variables.
T sp::math::Min | ( | const T & | A, | |
const T & | B | |||
) | [inline] |
Returns the smallest value of the specified variables.
T sp::math::MinMax | ( | const T & | Value, | |
const T & | Min, | |||
const T & | Max | |||
) | [inline] |
Returns the input value if it is inside the range "Min" and "Max. Otherwise the clamped range.
T sp::math::ModularPow | ( | T | Base, | |
T | Exp, | |||
const T & | Modulus | |||
) |
Computes the efficient modular pow value.
T | This type must support the following operators: %, =, *= and >>=. |
[in] | Base | Specifies the base value. |
[in] | Exp | Specifies the exponent value. |
[in] | Modulus | Specifies the modulus value. |
T sp::math::Pow2 | ( | const T & | Value | ) | [inline] |
Returns the square of the specified value (Value * Value).
T sp::math::Round | ( | const T & | Value, | |
s32 | Precision | |||
) | [inline] |
Returns the rounded value to the specified precision.
s32 sp::math::Round | ( | f32 | Value | ) | [inline] |
Rounds the float value to the nearest integer value (e.g. 3.4 to 3 and 3.5 to 4).
s32 sp::math::RoundPow2 | ( | s32 | Value | ) | [inline] |
Rounds the given value to the nearest power of two value (e.g. 34 to 32 and 120 to 128).
void sp::math::setBitL2R | ( | u32 & | Integer, | |
s32 | Pos, | |||
bool | Enable | |||
) | [inline] |
Sets the bit inside the specified integer at the specified position (left to right).
void sp::math::setBitL2R | ( | u8 & | Integer, | |
s32 | Pos, | |||
bool | Enable | |||
) | [inline] |
Sets the bit inside the specified integer at the specified position (left to right).
void sp::math::setBitR2L | ( | u8 & | Integer, | |
s32 | Pos, | |||
bool | Enable | |||
) | [inline] |
Sets the bit inside the specified integer at the specified position (right to left).
void sp::math::setBitR2L | ( | u32 & | Integer, | |
s32 | Pos, | |||
bool | Enable | |||
) | [inline] |
Sets the bit inside the specified integer at the specified position (right to left).
T sp::math::Sgn | ( | const T & | Value | ) | [inline] |
Returns the signed value. Resulting values can only be 1, -1 or 0.
T sp::math::Sin | ( | const T & | Value | ) | [inline] |
Returns the sine of the specified value as degree.
void sp::math::sortContainer | ( | std::vector< T > & | ObjectList, | |
bool(*)(T &obj1, T &obj2) | lpFuncCmp | |||
) |
void sp::math::sortContainerConst | ( | std::vector< T > & | ObjectList, | |
bool(*)(const T &obj1, const T &obj2) | lpFuncCmp | |||
) |
void sp::math::Swap | ( | T & | A, | |
T & | B | |||
) | [inline] |
Exchanges (or rather swaps) the content of the specified variables A and B.
T sp::math::Tan | ( | const T & | Value | ) | [inline] |
Returns the tangent of the specified value as degree.
const f32 sp::math::DEG = PI / 180.0f |
const f64 sp::math::DEG64 = PI64 / 180.0 |
const f32 sp::math::RAD = 180.0f / PI |
const f64 sp::math::RAD64 = 180.0 / PI64 |
const f64 sp::math::SQRT2 = sqrt(2.0) |
const f32 sp::math::SQRT2F = sqrtf(2.0f) |
const f64 sp::math::STDASPECT = 4.0 / 3.0 |