This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Math Common Functions

This class represents a collection of common math functions.

Notice
Math common functions are the members of the Unigine.MathLib namespace.

Math Class

Members


Abs ( float v ) #

Returns the absolute value of the argument.

Arguments

  • float v - Float value.

Return value

Absolute value.

Abs ( double v ) #

Returns the absolute value of the argument.

Arguments

  • double v - Value.

Return value

Absolute value.

int Abs ( int v ) #

Returns the absolute value of the argument.

Arguments

  • int v - Value.

Return value

Absolute value.

long Abs ( long v ) #

Returns the absolute value of the argument.

Arguments

  • long v - Value.

Return value

Absolute value.

vec2 Abs ( vec2 v ) #

Returns the absolute values of the vector components.

Arguments

  • vec2 v - Source vector.

Return value

Vector with absolute values.

vec3 Abs ( vec3 v ) #

Returns the absolute values of the vector components.

Arguments

  • vec3 v - Source vector.

Return value

Vector with absolute values.

vec4 Abs ( vec4 v ) #

Returns the absolute values of the vector components.

Arguments

  • vec4 v - Source vector.

Return value

Vector with absolute values.

dvec2 Abs ( dvec2 v ) #

Returns the absolute values of the vector components.

Arguments

Return value

Vector with absolute values.

dvec3 Abs ( dvec3 v ) #

Returns the absolute values of the vector components.

Arguments

Return value

Vector with absolute values.

dvec4 Abs ( dvec4 v ) #

Returns the absolute values of the vector components.

Arguments

Return value

Vector with absolute values.

ivec2 Abs ( ivec2 v ) #

Returns the absolute values of the vector components.

Arguments

Return value

Vector with absolute values.

ivec3 Abs ( ivec3 v ) #

Returns the absolute values of the vector components.

Arguments

Return value

Vector with absolute values.

ivec4 Abs ( ivec4 v ) #

Returns the absolute values of the vector components.

Arguments

Return value

Vector with absolute values.

float Bezier ( float [] t, float [] v, float time ) #

Calculates the value of a cubic Bezier function for t = time.

A cubic Bezier curve is represented by 4 points. Po is the start point, P1 and P2 are control points 1 and 2 and P3 is the end point. The start and end point denote the beginning and end points of the path and the control points determine how the path moves from the start to the finish. As can be seen from the image, the only variable changing is t which determines how far the path has progressed from P0 to P3. Cubic Bezier curves are used as timing functions particularly for keyframe interpolation.

Arguments

  • float [] t - Coordinates of the four points of the curve along the horizontal T (times) axis in the range [0.0f, 1.0f].
  • float [] v - Coordinates of the four points of the curve along the vertical V (values) axis in the range [0.0f, 1.0f].
  • float time - Time in the range [0, 1], for which the value of the Bezier function is to be calculated.

Return value

Value of the Bezier function.

double Bezier ( float [] t, double [] v, float time ) #

Calculates the value of a cubic Bezier function for t = time.

A cubic Bezier curve is represented by 4 points. Po is the start point, P1 and P2 are control points 1 and 2 and P3 is the end point. The start and end point denote the beginning and end points of the path and the control points determine how the path moves from the start to the finish. As can be seen from the image, the only variable changing is t which determines how far the path has progressed from P0 to P3. Cubic Bezier curves are used as timing functions particularly for keyframe interpolation.

Arguments

  • float [] t - Coordinates of the four points of the curve along the horizontal T (times) axis in the range [0.0f, 1.0f].
  • double [] v - Coordinates of the four points of the curve along the vertical V (values) axis in the range [0.0f, 1.0f].
  • float time - Time in the range [0, 1], for which the value of the Bezier function is to be calculated.

Return value

Value of the Bezier function.

vec4 BlueNoise ( int x, int y ) #

Returns a blue noise value for the given pixel coordinates.

Arguments

  • int x - X coordinate of the pixel.
  • int y - Y coordinate of the pixel.

Return value

Blue noise value.

float Ceil ( float v ) #

Ceiling function that returns the smallest integer value that is not less than the argument.
Source code
float a = ceil(3.141593); // a = 4.0

Arguments

  • float v - Argument.

Return value

Smallest integer value not less than v.

double Ceil ( double v ) #

Ceiling function that returns the smallest integer value that is not less than the argument.
Source code
double a = ceil(3.141593); // a = 4.0

Arguments

  • double v - Argument.

Return value

Smallest integer value not less than v.

vec2 Ceil ( vec2 v ) #

Ceiling function that returns the vector storing the smallest integer values that are not less than the argument.

Arguments

  • vec2 v - Vector storing values.

Return value

Vector storing the smallest integer values not less than v.

vec3 Ceil ( vec3 v ) #

Ceiling function that returns the vector storing the smallest integer values that are not less than the argument.

Arguments

  • vec3 v - Vector storing values.

Return value

Vector storing the smallest integer values not less than v.

vec4 Ceil ( vec4 v ) #

Ceiling function that returns the vector storing the smallest integer values that are not less than the argument.

Arguments

  • vec4 v - Vector storing values.

Return value

Vector storing the smallest integer values not less than v.

dvec2 Ceil ( dvec2 v ) #

Ceiling function that returns the vector storing the smallest integer values that are not less than the argument.

Arguments

  • dvec2 v - Vector storing values.

Return value

Vector storing the smallest integer values not less than v.

dvec3 Ceil ( dvec3 v ) #

Ceiling function that returns the vector storing the smallest integer values that are not less than the argument.

Arguments

  • dvec3 v - Vector storing values.

Return value

Vector storing the smallest integer values not less than v.

dvec4 Ceil ( dvec4 v ) #

Ceiling function that returns the vector storing the smallest integer values that are not less than the argument.

Arguments

  • dvec4 v - Vector storing values.

Return value

Vector storing the smallest integer values not less than v.

double ChangeRange ( double value, dvec4 range ) #

Transforms the value from the source range to the corresponding value within target range.

Arguments

  • double value - The value within the source range.
  • dvec4 range - The vector containing 4 values: values X and Y define the source range, values Z and W define the target range.

Return value

The value within the target range.

double Clamp ( double v, double v0, double v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • double v - Value to be clamped.
  • double v0 - Minimum value.
  • double v1 - Maximum value.

Return value

Clamped value.

float Clamp ( float v, float v0, float v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • float v - Value to be clamped.
  • float v0 - Minimum value.
  • float v1 - Maximum value.

Return value

Clamped value.

int Clamp ( int v, int v0, int v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • int v - Value to be clamped.
  • int v0 - Minimum value.
  • int v1 - Maximum value.

Return value

Clamped value.

char Clamp ( char v, char v0, char v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • char v - Value to be clamped.
  • char v0 - Minimum value.
  • char v1 - Maximum value.

Return value

Clamped value.

long Clamp ( long v, long v0, long v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • long v - Value to be clamped.
  • long v0 - Minimum value.
  • long v1 - Maximum value.

Return value

Clamped value.

dvec2 Clamp ( dvec2 v, dvec2 v0, dvec2 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • dvec2 v - Value to be clamped.
  • dvec2 v0 - Minimum value.
  • dvec2 v1 - Maximum value.

Return value

Clamped value.

ivec2 Clamp ( ivec2 v, ivec2 v0, ivec2 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

Return value

Clamped value.

vec2 Clamp ( vec2 v, vec2 v0, vec2 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • vec2 v - Value to be clamped.
  • vec2 v0 - Minimum value.
  • vec2 v1 - Maximum value.

Return value

Clamped value.

dvec3 Clamp ( dvec3 v, dvec3 v0, dvec3 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • dvec3 v - Value to be clamped.
  • dvec3 v0 - Minimum value.
  • dvec3 v1 - Maximum value.

Return value

Clamped value.

ivec3 Clamp ( ivec3 v, ivec3 v0, ivec3 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • ivec3 v - Value to be clamped.
  • ivec3 v0 - Minimum value.
  • ivec3 v1 - Maximum value.

Return value

Clamped value.

vec3 Clamp ( vec3 v, vec3 v0, vec3 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • vec3 v - Value to be clamped.
  • vec3 v0 - Minimum value.
  • vec3 v1 - Maximum value.

Return value

Clamped value.

bvec4 Clamp ( bvec4 v, bvec4 v0, bvec4 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • bvec4 v - Value to be clamped.
  • bvec4 v0 - Minimum value.
  • bvec4 v1 - Maximum value.

Return value

Clamped value.

dvec4 Clamp ( dvec4 v, dvec4 v0, dvec4 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • dvec4 v - Value to be clamped.
  • dvec4 v0 - Minimum value.
  • dvec4 v1 - Maximum value.

Return value

Clamped value.

ivec4 Clamp ( ivec4 v, ivec4 v0, ivec4 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • ivec4 v - Value to be clamped.
  • ivec4 v0 - Minimum value.
  • ivec4 v1 - Maximum value.

Return value

Clamped value.

vec4 Clamp ( vec4 v, vec4 v0, vec4 v1 ) #

Clamps a value within the specified min and max limits.

Arguments

  • vec4 v - Value to be clamped.
  • vec4 v0 - Minimum value.
  • vec4 v1 - Maximum value.

Return value

Clamped value.

Compare ( float v0, float v1 ) #

Compares two scalars of the float type according to the degree of precision equal to 1.0e-6f.

Arguments

  • float v0 - First float scalar.
  • float v1 - Second float scalar.

Return value

1 if v0 is equal to v1; otherwise, 0.

Compare ( double v0, double v1 ) #

Compares two scalars of the double type according to the degree of precision equal to 1.0e-6f.

Arguments

  • double v0 - First double scalar.
  • double v1 - Second double scalar.

Return value

1 if the v0 is equal to v1; otherwise, 0.

Compare ( float v0, float v1, float epsilon ) #

Compares two scalars of the float type according to the specified degree of precision.

Arguments

  • float v0 - First scalar.
  • float v1 - Second scalar.
  • float epsilon - Epsilon (degree of precision).

Return value

1 if the v0 is equal to v1; otherwise, 0.

Compare ( double v0, double v1, double epsilon ) #

Compares two scalars of the double type according to the specified degree of precision.

Arguments

  • double v0 - First scalar.
  • double v1 - Second scalar.
  • double epsilon - Epsilon (degree of precision).

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( vec2 v0, vec2 v1 ) #

Compares two vectors according to the degree of precision equal to 1.0e-6f.

Arguments

  • vec2 v0 - First vector.
  • vec2 v1 - Second vector.

Return value

1 if v0 is equal to v1; otherwise, 0.

int Compare ( vec2 v0, vec2 v1, float epsilon ) #

Compares two vectors according to the specified degree of precision.

Arguments

  • vec2 v0 - First vector.
  • vec2 v1 - Second vector.
  • float epsilon - Epsilon (degree of precision).

Return value

1 if v0 is equal to v1; otherwise, 0.

int Compare ( dvec2 v0, dvec2 v1 ) #

Compares two vectors according to the degree of precision equal to 1.0e-6f.

Arguments

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( dvec2 v0, dvec2 v1, double epsilon ) #

Compares two vectors according to the specified degree of precision.

Arguments

  • dvec2 v0 - First vector.
  • dvec2 v1 - Second vector.
  • double epsilon - Epsilon (degree of precision).

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( vec3 v0, vec3 v1 ) #

Compares two vectors according to the degree of precision equal to 1.0e-6f.

Arguments

  • vec3 v0 - First vector.
  • vec3 v1 - Second vector.

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( vec3 v0, vec3 v1, float epsilon ) #

Compares two vectors according to the specified degree of precision.

Arguments

  • vec3 v0 - First vector.
  • vec3 v1 - Second vector.
  • float epsilon - Epsilon (degree of precision).

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( dvec3 v0, dvec3 v1 ) #

Compares two vectors according to the degree of precision equal to 1.0e-6f.

Arguments

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( dvec3 v0, dvec3 v1, double epsilon ) #

Compares two vectors according to the specified degree of precision.

Arguments

  • dvec3 v0 - First vector.
  • dvec3 v1 - Second vector.
  • double epsilon - Epsilon (degree of precision).

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( vec4 v0, vec4 v1 ) #

Compares two vectors according to the degree of precision equal to 1.0e-6f.

Arguments

  • vec4 v0 - First vector.
  • vec4 v1 - Second vector.

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( vec4 v0, vec4 v1, float epsilon ) #

Compares two vectors according to the specified degree of precision.

Arguments

  • vec4 v0 - First vector.
  • vec4 v1 - Second vector.
  • float epsilon - Epsilon (degree of precision).

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( dvec4 v0, dvec4 v1 ) #

Compares two vectors according to the degree of precision equal to 1.0e-6f.

Arguments

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( dvec4 v0, dvec4 v1, double epsilon ) #

Compares two vectors according to the specified degree of precision.

Arguments

  • dvec4 v0 - First vector.
  • dvec4 v1 - Second vector.
  • double epsilon - Epsilon (degree of precision).

Return value

1 if the v0 is equal to v1; otherwise, 0.

int Compare ( quat q0, quat q1 ) #

Compares two quaternions according to the degree of precision equal to 1.0e-6f.

Arguments

  • quat q0 - First quaternion.
  • quat q1 - Second quaternion.

Return value

1 if the q0 is equal to q1; otherwise, 0.

int Compare ( quat q0, quat q1, float epsilon ) #

Compares two quaternions according to the specified degree of precision.

Arguments

  • quat q0 - First quaternion.
  • quat q1 - Second quaternion.
  • float epsilon - Epsilon (degree of precision).

Return value

1 if the q0 is equal to q1; otherwise, 0.

int Compare ( mat3 m0, mat3 m1 ) #

Compares two matrices according to the degree of precision equal to 1.0e-6f.

Arguments

  • mat3 m0 - First matrix.
  • mat3 m1 - Second matrix.

Return value

1 if the m0 is equal to m1; otherwise, 0.

int Compare ( mat3 m0, mat3 m1, float epsilon ) #

Compares two matrices according to the specified degree of precision.

Arguments

  • mat3 m0 - First matrix.
  • mat3 m1 - Second matrix.
  • float epsilon - Epsilon (degree of precision).

Return value

1 if the m0 is equal to m1; otherwise, 0.

int Compare ( mat4 m0, mat4 m1 ) #

Compares two matrices according to the degree of precision equal to 1.0e-6f.

Arguments

  • mat4 m0 - First matrix.
  • mat4 m1 - Second matrix.

Return value

1 if the m0 is equal to m1; otherwise, 0.

int Compare ( mat4 m0, mat4 m1, float epsilon ) #

Compares two matrices according to the specified degree of precision.

Arguments

  • mat4 m0 - First matrix.
  • mat4 m1 - Second matrix.
  • float epsilon - Epsilon (degree of precision).

Return value

1 if the m0 is equal to m1; otherwise, 0.

int Compare ( dmat4 m0, dmat4 m1 ) #

Compares two matrices according to the degree of precision equal to 1.0e-6f.

Arguments

Return value

1 if the m0 is equal to m1; otherwise, 0.

int Compare ( dmat4 m0, dmat4 m1, double epsilon ) #

Compares two matrices according to the specified degree of precision.

Arguments

  • dmat4 m0 - First matrix.
  • dmat4 m1 - Second matrix.
  • double epsilon - Epsilon (degree of precision).

Return value

1 if the m0 is equal to m1; otherwise, 0.

quat Conjugate ( quat q ) #

Returns the conjugate of a given quaternion.

Arguments

  • quat q - Quaternion.

Return value

Conjugate of a given quaternion.

float Cross ( vec2 v0, vec2 v1 ) #

Cross product of vectors.

Arguments

  • vec2 v0 - First vector.
  • vec2 v1 - Second vector.

Return value

Cross product of the two 2d vectors: v0.x * v1.y - v0.y*v1.x.

ivec3 Cross ( ivec3 v0, ivec3 v1 ) #

Cross product of vectors.

Arguments

Return value

Resulting vector.

dvec3 Cross ( dvec3 v0, dvec3 v1 ) #

Cross product of vectors.

Arguments

Return value

Resulting vector.

vec3 Cross ( vec3 v0, vec3 v1 ) #

Cross product of vectors.

Arguments

  • vec3 v0 - First vector.
  • vec3 v1 - Second vector.

Return value

Resulting vector.

void Cross ( out ivec3 ret, ivec3 v0, ivec3 v1 ) #

Cross product of vectors.

Arguments

  • out ivec3 ret - Output vector, to which the resulting vector will be put.
  • ivec3 v0 - First vector.
  • ivec3 v1 - Second vector.

Return value

void Cross ( out vec3 ret, vec3 v0, vec3 v1 ) #

Cross product of vectors.

Arguments

  • out vec3 ret - Output vector, to which the resulting vector will be put.
  • vec3 v0 - First vector.
  • vec3 v1 - Second vector.

Return value

void Cross ( out vec4 ret, vec3 v0, vec3 v1 ) #

Cross product of vectors.

Arguments

  • out vec4 ret - Output vector, to which the resulting vector will be put.
  • vec3 v0 - First vector.
  • vec3 v1 - Second vector.

Return value

void Cross ( out dvec3 ret, dvec3 v0, dvec3 v1 ) #

Cross product of vectors.

Arguments

  • out dvec3 ret - Output vector, to which the resulting vector will be put.
  • dvec3 v0 - First vector.
  • dvec3 v1 - Second vector.

Return value

void Cross ( out vec4 ret, dvec3 v0, dvec3 v1 ) #

Cross product of vectors.

Arguments

  • out vec4 ret - Output vector, to which the resulting vector will be put.
  • dvec3 v0 - First vector.
  • dvec3 v1 - Second vector.

Return value

float Dot ( vec2 v0, vec2 v1 ) #

Dot product of vectors.

Arguments

  • vec2 v0 - First vector.
  • vec2 v1 - Second vector.

Return value

Resulting scalar.

float Dot ( vec3 v0, vec3 v1 ) #

Dot product of vectors.

Arguments

  • vec3 v0 - First vector.
  • vec3 v1 - Second vector.

Return value

Resulting scalar.

double Dot ( dvec2 v0, dvec2 v1 ) #

Dot product of vectors.

Arguments

Return value

Resulting scalar.

float Dot ( vec3 v0, vec4 v1 ) #

Dot product of vectors. In this case, w component of the four-component vector is added to the dot product of first three components of vectors.

Arguments

  • vec3 v0 - First vector.
  • vec4 v1 - Second vector.

Return value

Resulting scalar.

float Dot ( vec4 v0, vec3 v1 ) #

Dot product of vectors. In this case, w component of the four-component vector is added to the dot product of first three components of vectors.

Arguments

  • vec4 v0 - First vector.
  • vec3 v1 - Second vector.

Return value

Resulting scalar.

float Dot ( vec4 v0, vec4 v1 ) #

Dot product of vectors.

Arguments

  • vec4 v0 - First vector.
  • vec4 v1 - Second vector.

Return value

Resulting scalar.

int Dot ( ivec3 v0, ivec3 v1 ) #

Dot product of vectors.

Arguments

Return value

Resulting scalar.

int Dot ( ivec2 v0, ivec2 v1 ) #

Dot product of vectors.

Arguments

Return value

Resulting scalar.

int Dot ( ivec4 v0, ivec3 v1 ) #

Dot product of vectors. In this case, w component of the four-component vector is added to the dot product of first three components of vectors.

Arguments

Return value

Resulting scalar.

int Dot ( ivec4 v0, ivec4 v1 ) #

Dot product of vectors.

Arguments

Return value

Resulting scalar.

double Dot ( dvec3 v0, dvec3 v1 ) #

Dot product of vectors.

Arguments

Return value

Resulting scalar.

double Dot ( dvec3 v0, dvec4 v1 ) #

Dot product of vectors. In this case, w component of the four-component vector is added to the dot product of first three components of vectors.

Arguments

Return value

Resulting scalar.

double Dot ( dvec4 v0, dvec3 v1 ) #

Dot product of vectors. In this case, w component of the four-component vector is added to the dot product of first three components of vectors.

Arguments

Return value

Resulting scalar.

double Dot ( dvec4 v0, dvec4 v1 ) #

Dot product of vectors.

Arguments

Return value

Resulting scalar.

double Dot3 ( dvec3 v0, dvec4 v1 ) #

Dot product of three components of vectors. W components of four-component vectors are ignored.
Source code (C#)
float a = MathLib.Dot3(new vec3(1, 2, 3), new vec4(1, 2, 3, 4));
double b = MathLib.Dot3(new dvec4(1, 2, 3, 4), new dvec4(1, 2, 3, 4));
/*
result is:
a = 14.000000
b = 14.000000
*/

Arguments

Return value

Resulting scalar.

double Dot3 ( dvec4 v0, dvec3 v1 ) #

Dot product of three components of vectors. W components of four-component vectors are ignored.
Source code (C#)
float a = MathLib.Dot3(new vec3(1, 2, 3), new vec4(1, 2, 3, 4));
double b = MathLib.Dot3(new dvec4(1, 2, 3, 4), new dvec4(1, 2, 3, 4));
/*
result is:
a = 14.000000
b = 14.000000
*/

Arguments

Return value

Resulting scalar.

double Dot3 ( dvec4 v0, dvec4 v1 ) #

Dot product of three components of vectors. W components of four-component vectors are ignored.
Source code (C#)
float a = MathLib.Dot3(new vec3(1, 2, 3), new vec4(1, 2, 3, 4));
double b = MathLib.Dot3(new dvec4(1, 2, 3, 4), new dvec4(1, 2, 3, 4));
/*
result is:
a = 14.000000
b = 14.000000
*/

Arguments

Return value

Resulting scalar.

float Dot3 ( vec3 v0, vec4 v1 ) #

Dot product of three components of vectors. W components of four-component vectors are ignored.
Source code (C#)
float a = MathLib.Dot3(new vec3(1, 2, 3), new vec4(1, 2, 3, 4));
double b = MathLib.Dot3(new dvec4(1, 2, 3, 4), new dvec4(1, 2, 3, 4));
/*
result is:
a = 14.000000
b = 14.000000
*/

Arguments

  • vec3 v0 - First vector.
  • vec4 v1 - Second vector.

Return value

Resulting scalar.

float Dot3 ( vec4 v0, vec3 v1 ) #

Dot product of three components of vectors. W components of four-component vectors are ignored.
Source code (C#)
float a = MathLib.Dot3(new vec3(1, 2, 3), new vec4(1, 2, 3, 4));
double b = MathLib.Dot3(new dvec4(1, 2, 3, 4), new dvec4(1, 2, 3, 4));
/*
result is:
a = 14.000000
b = 14.000000
*/

Arguments

  • vec4 v0 - First vector.
  • vec3 v1 - Second vector.

Return value

Resulting scalar.

float Dot3 ( vec4 v0, vec4 v1 ) #

Dot product of three components of vectors. W components of four-component vectors are ignored.
Source code (C#)
float a = MathLib.Dot3(new vec3(1, 2, 3), new vec4(1, 2, 3, 4));
double b = MathLib.Dot3(new dvec4(1, 2, 3, 4), new dvec4(1, 2, 3, 4));
/*
result is:
a = 14.000000
b = 14.000000
*/

Arguments

  • vec4 v0 - First vector.
  • vec4 v1 - Second vector.

Return value

Resulting scalar.

float Dtof ( double v ) #

Converts a double value to an integer value.

Arguments

  • double v - Double value.

Return value

Float value.

int Dtoi ( double v ) #

Converts a double value to an integer value.

Arguments

  • double v - Double value.

Return value

Integer value.

long Dtol ( double v ) #

Converts a double value to a long value.

Arguments

  • double v - Double value.

Return value

Long value.

double Floor ( double v ) #

Rounds an argument down to the nearest integer.
Source code
float a = floor(2.3) // a = 2.0

Arguments

  • double v - Argument.

Return value

Largest integer value not greater than arg.

float Floor ( float v ) #

Rounds an argument down to the nearest integer.
Source code
double a = floor(2.3) // a = 2.0

Arguments

  • float v - Argument.

Return value

Largest integer value not greater than arg.

vec2 Floor ( vec2 v ) #

Ceiling function that returns the vector storing the largest integer values that are not greater than the argument.

Arguments

  • vec2 v - Vector storing values.

Return value

Vector storing the largest integer values not greater than v.

vec3 Floor ( vec3 v ) #

Ceiling function that returns the vector storing the largest integer values that are not greater than the argument.

Arguments

  • vec3 v - Vector storing values.

Return value

Vector storing the largest integer values not greater than v.

vec4 Floor ( vec4 v ) #

Ceiling function that returns the vector storing the largest integer values that are not greater than the argument.

Arguments

  • vec4 v - Vector storing values.

Return value

Vector storing the largest integer values not greater than v.

dvec2 Floor ( dvec2 v ) #

Ceiling function that returns the vector storing the largest integer values that are not greater than the argument.

Arguments

  • dvec2 v - Vector storing values.

Return value

Vector storing the largest integer values not greater than v.

dvec3 Floor ( dvec3 v ) #

Ceiling function that returns the vector storing the largest integer values that are not greater than the argument.

Arguments

  • dvec3 v - Vector storing values.

Return value

Vector storing the largest integer values not greater than v.

dvec4 Floor ( dvec4 v ) #

Ceiling function that returns the vector storing the largest integer values that are not greater than the argument.

Arguments

  • dvec4 v - Vector storing values.

Return value

Vector storing the largest integer values not greater than v.

float Frac ( float v ) #

Returns the fractional part of the argument.
Source code
float a = frac(3.141593); // a = 0.141593

Arguments

  • float v - Argument.

Return value

Fractional part of the argument.

double Frac ( double v ) #

Returns the fractional part of the argument.
Source code
double a = frac(3.141593); // a = 0.141593

Arguments

  • double v - Argument.

Return value

Fractional part of the argument.

vec3 Frac ( vec3 v ) #

Returns the fractional part every component of the argument.

Arguments

Return value

Fractional part of every component of the argument.

vec4 Frac ( vec4 v ) #

Returns the fractional part every component of the argument.

Arguments

Return value

Fractional part of every component of the argument.

sbyte Ftoc ( float v ) #

Converts a float value to a char value.

Arguments

  • float v - Float value.

Return value

Char value.

int Ftoi ( float v ) #

Converts a float value to an integer value.

Arguments

  • float v - Float value.

Return value

Integer value.

long Ftol ( float v ) #

Converts a float value to a long value.

Arguments

  • float v - Float value.

Return value

Long value.

float GetAngle ( quat q0, quat q1 ) #

Returns the angle (in degrees) between the given first and second quaternions. The angle returned is the unsigned acute angle between the two quaternions. This means the smaller of the two possible angles is used.

Arguments

  • quat q0 - First quaternion (from which the angular difference is measured).
  • quat q1 - Second quaternion (to which the angular difference is measured).

Return value

Angle between the given quaternions, in degrees within the range [0.0; 180.0].

float GetAngle ( vec3 v0, vec3 v1 ) #

Returns the angle (in degrees) between the given first and second vectors. The angle returned is the unsigned acute angle between the two vectors. This means the smaller of the two possible angles is used.

Arguments

  • vec3 v0 - First vector (from which the angular difference is measured).
  • vec3 v1 - Second vector (to which the angular difference is measured).

Return value

Angle between the given vectors, in degrees within the range [0.0; 180.0].

float GetAngle ( vec3 v0, vec3 v1, vec3 up ) #

Returns the signed angle (in degrees) between the given first and second vectors relative to the specified "up" vector.

Arguments

  • vec3 v0 - First vector (from which the angular difference is measured).
  • vec3 v1 - Second vector (to which the angular difference is measured).
  • vec3 up - Up vector, around which the other two vectors are rotated.

Return value

Angle between the given vectors, in degrees within the range [-180.0; 180.0].

float Gradient4 ( float x, vec4 gradient ) #

Returns a gradient value for the specified argument using four key components. The gradient value is determined as follows:
Source code
smoothstep(gradient.x, gradient.y, x) - smoothstep(gradient.z, gradient.w, x);
See the smoothstep() method.

Arguments

  • float x - Argument.
  • vec4 gradient - Vector with four key components.

Return value

Gradient value.

float InverseLerp ( float v0, float v1, float v ) #

Returns the value calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0f and 1.0f.

Arguments

  • float v0 - The value specifying the beginning of the interval.
  • float v1 - The value specifying the ending of the interval.
  • float v - The value within the specified interval.

Return value

Coefficient of the value within a specified interval.

double InverseLerp ( double v0, double v1, double v ) #

Returns the value calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0 and 1.0.

Arguments

  • double v0 - The value specifying the beginning of the interval.
  • double v1 - The value specifying the ending of the interval.
  • double v - The value within the specified interval.

Return value

Coefficient of the value within a specified interval.

vec2 InverseLerp ( vec2 v0, vec2 v1, vec2 v ) #

Returns the vector with two float values calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0f and 1.0f.

Arguments

  • vec2 v0 - Vector storing the values that specify the beginnings of the intervals.
  • vec2 v1 - Vector storing the values that specify the endings of the intervals.
  • vec2 v - The values within the specified intervals.

Return value

Coefficients of the values within a specified intervals.

vec3 InverseLerp ( vec3 v0, vec3 v1, vec3 v ) #

Returns the vector with three float values calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0f and 1.0f.

Arguments

  • vec3 v0 - Vector storing the values that specify the beginnings of the intervals.
  • vec3 v1 - Vector storing the values that specify the endings of the intervals.
  • vec3 v - The values within the specified intervals.

Return value

Coefficients of the values within a specified intervals.

vec4 InverseLerp ( vec4 v0, vec4 v1, vec4 v ) #

Returns the vector with four float values calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0f and 1.0f.

Arguments

  • vec4 v0 - Vector storing the values that specify the beginnings of the intervals.
  • vec4 v1 - Vector storing the values that specify the endings of the intervals.
  • vec4 v - The values within the specified intervals.

Return value

Coefficients of the values within a specified intervals.

dvec2 InverseLerp ( dvec2 v0, dvec2 v1, dvec2 v ) #

Returns the vector with two double values calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0 and 1.0.

Arguments

  • dvec2 v0 - Vector storing the values that specify the beginnings of the intervals.
  • dvec2 v1 - Vector storing the values that specify the endings of the intervals.
  • dvec2 v - The values within the specified intervals.

Return value

Coefficients of the values within a specified intervals.

dvec3 InverseLerp ( dvec3 v0, dvec3 v1, dvec3 v ) #

Returns the vector with three double values calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0 and 1.0.

Arguments

  • dvec3 v0 - Vector storing the values that specify the beginnings of the intervals.
  • dvec3 v1 - Vector storing the values that specify the endings of the intervals.
  • dvec3 v - The values within the specified intervals.

Return value

Coefficients of the values within a specified intervals.

vec4 InverseLerp ( dvec4 v0, dvec4 v1, dvec4 v ) #

Returns the vector with four double values calculated according to the following formula: (v - v0) / (v1 - v0) clamped within 0.0 and 1.0.

Arguments

  • dvec4 v0 - Vector storing the values that specify the beginnings of the intervals.
  • dvec4 v1 - Vector storing the values that specify the endings of the intervals.
  • dvec4 v - The values within the specified intervals.

Return value

Coefficients of the values within a specified intervals.

float Isrgb ( float x ) #

Converts sRGB color value to RGB format.

Arguments

  • float x - sRGB value to convert.

Return value

RGB color value.

vec2 Isrgb ( vec2 color ) #

Converts sRGB color value to RGB format.

Arguments

  • vec2 color - sRGB value to convert.

Return value

RGB color value.

vec3 Isrgb ( vec3 color ) #

Converts sRGB color value to RGB format.

Arguments

  • vec3 color - sRGB value to convert.

Return value

RGB color value.

vec4 Isrgb ( vec4 color ) #

Converts sRGB color value and alpha to RGB format.

Arguments

  • vec4 color - sRGB value to convert.

Return value

RGB color value.

vec4 IsrgbColor ( vec4 color ) #

Converts sRGB color value to RGB format without converting alpha.

Arguments

  • vec4 color - sRGB value to convert.

Return value

RGB color value.

double Itod ( int v ) #

Converts an integer value to a double value.

Arguments

  • int v - Integer value.

Return value

Double value.

float Itof ( int v ) #

Converts an integer value to a float value.

Arguments

  • int v - Integer value.

Return value

Float value.

Scalar Itos ( int v ) #

Converts an integer value to a scalar value (float or double, depending on the precision).

Arguments

  • int v - Integer value.

Return value

Scalar value (float or double, depending on the precision).

float Length ( vec2 v ) #

Calculates the length of a given vector.

Arguments

Return value

Vector length.

double Length ( dvec2 v ) #

Calculates the length of a given vector.

Arguments

Return value

Vector length.

float Length ( vec3 v ) #

Calculates the length of a given vector.

Arguments

Return value

Vector length.

double Length ( dvec3 v ) #

Calculates the length of a given vector.

Arguments

Return value

Vector length.

float Length ( vec4 v ) #

Calculates the length of a given vector.

Arguments

Return value

Vector length.

double Length ( dvec4 v ) #

Calculates the length of a given vector.

Arguments

Return value

Vector length.

float Length2 ( vec2 v ) #

Calculates the squared length of a given vector. This method is much faster than length() - the calculation is basically the same only without the slow Sqrt call. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

double Length2 ( dvec2 v ) #

Calculates the squared length of a given vector. This method is much faster than length() - the calculation is basically the same only without the slow Sqrt call. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

int Length2 ( ivec2 v ) #

Calculates the squared length of a given vector. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

float Length2 ( vec3 v ) #

Calculates the squared length of a given vector. This method is much faster than length() - the calculation is basically the same only without the slow Sqrt call. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

double Length2 ( dvec3 v ) #

Calculates the squared length of a given vector. This method is much faster than length() - the calculation is basically the same only without the slow Sqrt call. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

int Length2 ( ivec3 v ) #

Calculates the squared length of a given vector. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

float Length2 ( vec4 v ) #

Calculates the squared length of a given vector. This method is much faster than length() - the calculation is basically the same only without the slow Sqrt call. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

double Length2 ( dvec4 v ) #

Calculates the squared length of a given vector. This method is much faster than length() - the calculation is basically the same only without the slow Sqrt call. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

int Length2 ( ivec4 v ) #

Calculates the squared length of a given vector. If you are using lengths simply to compare distances, then it is faster to compare squared lengths against the squares of distances as the comparison gives the same result.

Arguments

Return value

Squared length of the vector (X 2 + Y 2 + Z 2).

float Lerp ( float v0, float v1, float k ) #

Returns the interpolated value according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • float v0 - First float value.
  • float v1 - Second float value.
  • float k - Interpolation coefficient.

Return value

Interpolated value.

double Lerp ( double v0, double v1, double k ) #

Returns the interpolated value according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • double v0 - First double value.
  • double v1 - Second double value.
  • double k - Interpolation coefficient.

Return value

Interpolated value.

int Lerp ( int v0, int v1, int k ) #

Returns the interpolated value according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • int v0 - First int value.
  • int v1 - Second int value.
  • int k - Interpolation coefficient.

Return value

Interpolated value.

const vec2 & Lerp ( vec2 v0, vec2 v1, float k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • vec2 v0 - First vector.
  • vec2 v1 - Second vector.
  • float k - Interpolation coefficient.

Return value

Interpolated vector.

vec3 Lerp ( vec3 v0, vec3 v1, float k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • vec3 v0 - First vector.
  • vec3 v1 - Second vector.
  • float k - Interpolation coefficient.

Return value

Interpolated vector.

vec4 Lerp ( vec4 v0, vec4 v1, float k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • vec4 v0 - First vector.
  • vec4 v1 - Second vector.
  • float k - Interpolation coefficient.

Return value

Interpolated vector.

dvec2 Lerp ( dvec2 v0, dvec2 v1, double k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • dvec2 v0 - First vector.
  • dvec2 v1 - Second vector.
  • double k - Interpolation coefficient.

Return value

Interpolated vector.

dvec3 Lerp ( dvec3 v0, dvec3 v1, double k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • dvec3 v0 - First vector.
  • dvec3 v1 - Second vector.
  • double k - Interpolation coefficient.

Return value

Interpolated vector.

dvec4 Lerp ( dvec4 v0, dvec4 v1, double k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • dvec4 v0 - First vector.
  • dvec4 v1 - Second vector.
  • double k - Interpolation coefficient.

Return value

Interpolated vector.

ivec2 Lerp ( ivec2 v0, ivec2 v1, int k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • ivec2 v0 - First vector.
  • ivec2 v1 - Second vector.
  • int k - Interpolation coefficient.

Return value

Interpolated vector.

ivec3 Lerp ( ivec3 v0, ivec3 v1, int k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • ivec3 v0 - First vector.
  • ivec3 v1 - Second vector.
  • int k - Interpolation coefficient.

Return value

Interpolated vector.

ivec4 Lerp ( ivec4 v0, ivec4 v1, int k ) #

Returns the interpolated vector according to the following formula: v0 + (v 1 - v 0) * k .

Arguments

  • ivec4 v0 - First vector.
  • ivec4 v1 - Second vector.
  • int k - Interpolation coefficient.

Return value

Interpolated vector.

float Ltof ( long v ) #

Converts a long value to a float value.

Arguments

  • long v - Long value.

Return value

Float value.

double Ltod ( long v ) #

Converts a long value to a double value.

Arguments

  • long v - Long value.

Return value

Double value.

Max ( float v0, float v1 ) #

Returns the maximum value.

Arguments

  • float v0 - First value.
  • float v1 - Second value.

Return value

Maximum value.

Max ( double v0, double v1 ) #

Returns the maximum value.

Arguments

  • double v0 - First value.
  • double v1 - Second value.

Return value

Maximum value.

Max ( int v0, int v1 ) #

Returns the maximum value.

Arguments

  • int v0 - First value.
  • int v1 - Second value.

Return value

Maximum value.

long Max ( long v0, long v1 ) #

Returns the maximum value.

Arguments

  • long v0 - First value.
  • long v1 - Second value.

Return value

Maximum value.

vec2 Max ( vec2 v0, vec2 v1 ) #

Returns the maximum value.

Arguments

  • vec2 v0 - First value.
  • vec2 v1 - Second value.

Return value

Maximum value.

vec3 Max ( vec3 v0, vec3 v1 ) #

Returns the maximum value.

Arguments

  • vec3 v0 - First value.
  • vec3 v1 - Second value.

Return value

Maximum value.

vec4 Max ( vec4 v0, vec4 v1 ) #

Returns the maximum value.

Arguments

  • vec4 v0 - First value.
  • vec4 v1 - Second value.

Return value

Maximum value.

dvec2 Max ( dvec2 v0, dvec2 v1 ) #

Returns the maximum value.

Arguments

Return value

Maximum value.

dvec3 Max ( dvec3 v0, dvec3 v1 ) #

Returns the maximum value.

Arguments

Return value

Maximum value.

dvec4 Max ( dvec4 v0, dvec4 v1 ) #

Returns the maximum value.

Arguments

Return value

Maximum value.

ivec2 Max ( ivec2 v0, ivec2 v1 ) #

Returns the maximum value.

Arguments

Return value

Maximum value.

ivec3 Max ( ivec3 v0, ivec3 v1 ) #

Returns the maximum value.

Arguments

Return value

Maximum value.

ivec4 Max ( ivec4 v0, ivec4 v1 ) #

Returns the maximum value.

Arguments

Return value

Maximum value.

bvec4 Max ( bvec4 v0, bvec4 v1 ) #

Returns the maximum value.

Arguments

Return value

Maximum value.

float Min ( float v0, float v1 ) #

Returns the minimum value.

Arguments

  • float v0 - First value.
  • float v1 - Second value.

Return value

Minimum value.

double Min ( double v0, double v1 ) #

Returns the minimum value.

Arguments

  • double v0 - First value.
  • double v1 - Second value.

Return value

Minimum value.

int Min ( int v0, int v1 ) #

Returns the minimum value.

Arguments

  • int v0 - First value.
  • int v1 - Second value.

Return value

Minimum value.

long Min ( long v0, long v1 ) #

Returns the minimum value.

Arguments

  • long v0 - First value.
  • long v1 - Second value.

Return value

Minimum value.

vec2 Min ( vec2 v0, vec2 v1 ) #

Returns the minimum value.

Arguments

  • vec2 v0 - First value.
  • vec2 v1 - Second value.

Return value

Minimum value.

vec3 Min ( vec3 v0, vec3 v1 ) #

Returns the minimum value.

Arguments

  • vec3 v0 - First value.
  • vec3 v1 - Second value.

Return value

Minimum value.

vec4 Min ( vec4 v0, vec4 v1 ) #

Returns the minimum value.

Arguments

  • vec4 v0 - First value.
  • vec4 v1 - Second value.

Return value

Minimum value.

dvec2 Min ( dvec2 v0, dvec2 v1 ) #

Returns the minimum value.

Arguments

Return value

Minimum value.

dvec3 Min ( dvec3 v0, dvec3 v1 ) #

Returns the minimum value.

Arguments

Return value

Minimum value.

dvec4 Min ( dvec4 v0, dvec4 v1 ) #

Returns the minimum value.

Arguments

Return value

Minimum value.

ivec2 Min ( ivec2 v0, ivec2 v1 ) #

Returns the minimum value.

Arguments

Return value

Minimum value.

ivec3 Min ( ivec3 v0, ivec3 v1 ) #

Returns the minimum value.

Arguments

Return value

Minimum value.

ivec4 Min ( ivec4 v0, ivec4 v1 ) #

Returns the minimum value.

Arguments

Return value

Minimum value.

bvec4 Min ( bvec4 v0, bvec4 v1 ) #

Returns the minimum value.

Arguments

Return value

Minimum value.

quat Normalize ( quat v ) #

Normalizes a quaternion, makes its magnitude equal to 1. When normalized, a quaternion keeps the same oreintation but its magnitude is equal to 1.

Arguments

Return value

Normalized quaternion.

vec2 Normalize ( vec2 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1.

Arguments

  • vec2 v - A two-component vec2 vector to be normalized.

Return value

Normalized vector.

vec3 Normalize ( vec3 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1.

Arguments

  • vec3 v - A three-component vec3 vector to be normalized.

Return value

Normalized vector.

vec4 Normalize ( vec4 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1.

Arguments

  • vec4 v - A four-component vec4 vector to be normalized.

Return value

Normalized vector.

dvec2 Normalize ( dvec2 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1.

Arguments

  • dvec2 v - A two-component dvec2 vector to be normalized.

Return value

Normalized vector.

dvec3 Normalize ( dvec3 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1.

Arguments

  • dvec3 v - A three-component dvec3 vector to be normalized.

Return value

Normalized vector.

dvec4 Normalize ( dvec4 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1.

Arguments

  • dvec4 v - A four-component dvec4 vector to be normalized.

Return value

Normalized vector.

quat NormalizeValid ( quat v ) #

Normalizes a quaternion, makes its magnitude equal to 1. When normalized, a quaternion keeps the same oreintation but its magnitude is equal to 1. Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

Return value

Normalized quaternion.

vec2 NormalizeValid ( vec2 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1. Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • vec2 v - A two-component vec2 vector to be normalized.

Return value

Normalized vector.

vec3 NormalizeValid ( vec3 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1. Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • vec3 v - A three-component vec3 vector to be normalized.

Return value

Normalized vector.

vec4 NormalizeValid ( vec4 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1. Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • vec4 v - A four-component vec4 vector to be normalized.

Return value

Normalized vector.

dvec2 NormalizeValid ( dvec2 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1. Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • dvec2 v - A two-component dvec2 vector to be normalized.

Return value

Normalized vector.

dvec3 NormalizeValid ( dvec3 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1. Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • dvec3 v - A three-component dvec3 vector to be normalized.

Return value

Normalized vector.

dvec4 NormalizeValid ( dvec4 v ) #

Normalizes a vector, makes its magnitude equal to 1. When normalized, a vector keeps the same direction but its length is equal to 1. Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • dvec4 v - A four-component dvec4 vector to be normalized.

Return value

Normalized vector.

vec4 Normalize3 ( vec4 v ) #

Normalizes a vector making its magnitude equal to 1. The vector is normalized as if it has only the first three components (the fourth one is ignored).

Arguments

  • vec4 v - A four-component vec4 vector to be normalized.

Return value

Normalized vector.

dvec4 Normalize3 ( dvec4 v ) #

Normalizes a vector making its magnitude equal to 1. The vector is normalized as if it has only the first three components (the fourth one is ignored).

Arguments

  • dvec4 v - A four-component dvec4 vector to be normalized.

Return value

Normalized vector.

vec4 NormalizeValid3 ( vec4 v ) #

Normalizes a vector making its magnitude equal to 1. The vector is normalized as if it has only the first three components (the fourth one is ignored). Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • vec4 v - A four-component vec4 vector to be normalized.

Return value

Normalized vector.

dvec4 NormalizeValid3 ( dvec4 v ) #

Normalizes a vector making its magnitude equal to 1. The vector is normalized as if it has only the first three components (the fourth one is ignored). Check for the zero vector is performed: if the argument is a zero vector, then a zero vector is returned.

Arguments

  • dvec4 v - A four-component dvec4 vector to be normalized.

Return value

Normalized vector.

int Npot ( int arg ) #

Rounds up to the nearest power of two value.

Arguments

  • int arg - Argument.

Return value

The nearest upper power of 2 number.

float Rcp ( float v ) #

Returns the reciprocal of the specified argument.

Arguments

  • float v - Argument.

Return value

Reciprocal of the argument.

double Rcp ( double v ) #

Returns the reciprocal of the specified argument.

Arguments

  • double v - Argument.

Return value

Reciprocal of the argument.

double Round ( double v ) #

Rounds an argument to the nearest integer value.
Notice
In halfway cases, when an argument has a fractional part of exactly 0.5, the function rounds away from zero to the integer with larger magnitude.
  • 3.5 -> 4
  • - 3.5 -> - 4
Source code
double a = round(2.3)  					// a = 2.0
double b = round(5.5)  					// b = 6.0
double c = round(-5.5) 					// c = -6.0

Arguments

  • double v - Argument.

Return value

Nearest integer value to the argument.

float Round ( float v ) #

Rounds an argument to the nearest integer value.
Notice
In halfway cases, when an argument has a fractional part of exactly 0.5, the function rounds away from zero to the integer with larger magnitude.
  • 3.5 -> 4
  • - 3.5 -> - 4
Source code
float a = round(2.3)  					// a = 2.0
float b = round(5.5)  					// b = 6.0
float c = round(-5.5) 					// c = -6.0

Arguments

  • float v - Argument.

Return value

Nearest integer value to the argument.

float Saturate ( float v ) #

Clamps the value within the range of 0.0 to 1.0.

Arguments

  • float v - Argument.

Return value

Argument value clamped within the range of 0.0 to 1.0.

double Saturate ( double v ) #

Clamps the value within the range of 0.0 to 1.0.

Arguments

  • double v - Argument.

Return value

Argument value clamped within the range of 0.0 to 1.0.

dvec2 Saturate ( dvec2 v ) #

Clamps the values of vector components within the range of 0.0 to 1.0.

Arguments

vec2 Saturate ( vec2 v ) #

Clamps the values of vector components within the range of 0.0 to 1.0.

Arguments

Return value

Vector with components clamped within the range of 0.0 to 1.0.

dvec3 Saturate ( dvec3 v ) #

Clamps the values of vector components within the range of 0.0 to 1.0.

Arguments

Return value

Vector with components clamped within the range of 0.0 to 1.0.

vec3 Saturate ( vec3 v ) #

Clamps the values of vector components within the range of 0.0 to 1.0.

Arguments

Return value

Vector with components clamped within the range of 0.0 to 1.0.

dvec4 Saturate ( dvec4 v ) #

Clamps the values of vector components within the range of 0.0 to 1.0.

Arguments

Return value

Vector with components clamped within the range of 0.0 to 1.0.

vec4 Saturate ( vec4 v ) #

Clamps the values of vector components within the range of 0.0 to 1.0.

Arguments

Return value

Vector with components clamped within the range of 0.0 to 1.0.

float Sign ( float v ) #

Returns the sign of the argument.

Arguments

  • float v - Argument.

Return value

Sign of the argument. 1.0 if v >= 0.0 ; -1.0 if v < 0.0.

double Sign ( double v ) #

Returns the sign of the argument.

Arguments

  • double v - Argument.

Return value

Sign of the argument. 1.0 if v >= 0.0 ; -1.0 if v < 0.0.

quat Slerp ( quat q0, quat q1, float k ) #

Spherical interpolation between two given quaternions.

Arguments

  • quat q0 - The value of the first quaternion.
  • quat q1 - The value of the second quaternion.
  • float k - The current position (from 0 to 1).

Return value

Resulting quaternion.

float Smoothstep ( float x ) #

Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [0, 1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • float x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than 0;
  • 1 if x is greater than 1;
  • interpolated value between 0 and 1 if x is in the range [0, 1].

double Smoothstep ( double x ) #

Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [0, 1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • double x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than 0;
  • 1 if x is greater than 1;
  • interpolated value between 0 and 1 if x is in the range [0, 1].

float Smoothstep ( float edge0, float edge1, float x ) #

Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [edge0, edge1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • float edge0 - Left edge value.
  • float edge1 - Right edge value.
  • float x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than edge0;
  • 1 if x is greater than edge1;
  • interpolated value between 0 and 1 if x is in the range [edge0, edge1].

double Smoothstep ( double edge0, double edge1, double x ) #

Returns a smooth Hermite interpolation between 0 and 1, if x is in the range [edge0, edge1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • double edge0 - Left edge value.
  • double edge1 - Right edge value.
  • double x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than edge0;
  • 1 if x is greater than edge1;
  • interpolated value between 0 and 1 if x is in the range [edge0, edge1].

float Smootherstep ( float x ) #

Returns a smooth interpolation between 0 and 1 using a fifth-order polynomial function, if x is in the range [0, 1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • float x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than 0;
  • 1 if x is greater than 1;
  • interpolated value between 0 and 1 if x is in the range [0, 1].

double Smootherstep ( double x ) #

Returns a smooth interpolation between 0 and 1 using a fifth-order polynomial function, if x is in the range [0, 1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • double x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than 0;
  • 1 if x is greater than 1;
  • interpolated value between 0 and 1 if x is in the range [0, 1].

float Smootherstep ( float edge0, float edge1, float x ) #

Returns a smooth interpolation between 0 and 1 using a fifth-order polynomial function, if x is in the range [edge0, edge1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • float edge0 - Left edge value.
  • float edge1 - Right edge value.
  • float x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than edge0;
  • 1 if x is greater than edge1;
  • interpolated value between 0 and 1 if x is in the range [edge0, edge1].

double Smootherstep ( double edge0, double edge1, double x ) #

Returns a smooth interpolation between 0 and 1 using a fifth-order polynomial function, if x is in the range [edge0, edge1].

It is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.

Arguments

  • double edge0 - Left edge value.
  • double edge1 - Right edge value.
  • double x - Value to be interpolated.

Return value

One of the following values:
  • 0 if x is less than edge0;
  • 1 if x is greater than edge1;
  • interpolated value between 0 and 1 if x is in the range [edge0, edge1].

float Srgb ( float x ) #

Converts RGB color value to sRGB format.

Arguments

  • float x - Value to convert.

Return value

sRGB color value.

vec2 Srgb ( vec2 color ) #

Converts RGB color value to sRGB format.

Arguments

  • vec2 color - Value to convert.

Return value

sRGB color value.

vec3 Srgb ( vec3 color ) #

Converts RGB color value to sRGB format.

Arguments

  • vec3 color - Value to convert.

Return value

sRGB color value.

vec4 Srgb ( vec4 color ) #

Converts RGB color value and alpha to sRGB format.

Arguments

  • vec4 color - Value to convert.

Return value

sRGB color value.

vec4 SrgbColor ( vec4 color ) #

Converts RGB color value to sRGB format without converting alpha.

Arguments

  • vec4 color - Value to convert.

Return value

sRGB color value.

float ToFloat ( double v ) #

Converts a double value to a float value.

Arguments

  • double v - Double value.

Return value

Float value.

float ToFloat ( long double v ) #

Converts a long double value to a float value.

Arguments

  • long double v - Long double value.

Return value

Float value.

float ToFloat ( sbyte v ) #

Converts a character value to a float value.

Arguments

  • sbyte v - Sbyte value.

Return value

Float value.

float ToFloat ( int v ) #

Converts an integer value to a float value.

Arguments

  • int v - Integer value.

Return value

Float value.

float ToFloat ( long v ) #

Converts a long value to a float value.

Arguments

  • long v - Long value.

Return value

Float value.

float ToFloat ( bool v ) #

Converts a boolean value to a float value.

Arguments

  • bool v - Boolean value.

Return value

Float value.

double ToDouble ( float value ) #

Converts a float value to a double value.

Arguments

  • float value - Float value.

Return value

Double value.

double ToDouble ( sbyte value ) #

Converts a character value to a double value.

Arguments

  • sbyte value - Sbyte value.

Return value

Double value.

double ToDouble ( int value ) #

Converts an integer value to a double value.

Arguments

  • int value - Integer value.

Return value

Double value.

double ToDouble ( long value ) #

Converts a long value to a double value.

Arguments

  • long value - Long value.

Return value

Double value.

double ToDouble ( bool value ) #

Converts a boolean value to a double value.

Arguments

  • bool value - Boolean value.

Return value

Double value.

int ToInt ( float value ) #

Converts a float value to an integer value.

Arguments

  • float value - Float value.

Return value

Integer value.

int ToInt ( double value ) #

Converts a double value to an integer value.

Arguments

  • double value - Double value.

Return value

Integer value.

int ToInt ( sbyte value ) #

Converts a character value to an integer value.

Arguments

  • sbyte value - Sbyte value.

Return value

Integer value.

int ToInt ( long value ) #

Converts a long value to an integer value.

Arguments

  • long value - Long value.

Return value

Integer value.

int ToInt ( bool value ) #

Converts a boolean value to an integer value.

Arguments

  • bool value - Boolean value.

Return value

Integer value.

sbyte ToChar ( float value ) #

Converts a float value to a character value.

Arguments

  • float value - Float value.

Return value

Sbyte value.

sbyte ToChar ( double value ) #

Converts a double value to a character value.

Arguments

  • double value - Double value.

Return value

Sbyte value.

sbyte ToChar ( int value ) #

Converts an integer value to a character value.

Arguments

  • int value - Integer value.

Return value

Sbyte value.

sbyte ToChar ( long value ) #

Converts a long value to a character value.

Arguments

  • long value - Long value.

Return value

Sbyte value.

sbyte ToChar ( bool value ) #

Converts a boolean value to a character value.

Arguments

  • bool value - Boolean value.

Return value

Sbyte value.

byte ToUChar ( float value ) #

Converts a float value to an unsigned character value.

Arguments

  • float value - Float value.

Return value

Byte value.

byte ToUChar ( double value ) #

Converts a double value to an unsigned character value.

Arguments

  • double value - Double value.

Return value

Byte value.

byte ToUChar ( int value ) #

Converts an integer value to an unsigned character value.

Arguments

  • int value - Integer value.

Return value

Byte value.

byte ToUChar ( long value ) #

Converts a long value to an unsigned character value.

Arguments

  • long value - Long value.

Return value

Byte value.

byte ToUChar ( bool value ) #

Converts a boolean value to an unsigned character value.

Arguments

  • bool value - Boolean value.

Return value

Byte value.

bool ToBool ( float value ) #

Converts a float value to a boolean value.

Arguments

  • float value - Float value.

Return value

Boolean value.

bool ToBool ( double value ) #

Converts a double value to a boolean value.

Arguments

  • double value - Double value.

Return value

Boolean value.

bool ToBool ( int value ) #

Converts an integer value to a boolean value.

Arguments

  • int value - Integer value.

Return value

Boolean value.

bool ToBool ( sbyte value ) #

Converts a character value to a boolean value.

Arguments

  • sbyte value - Sbyte value.

Return value

Boolean value.

bool ToBool ( long value ) #

Converts a long value to a boolean value.

Arguments

  • long value - Long value.

Return value

Boolean value.

int Udiv ( int x, int y ) #

Performs integer division with rounding up.

Arguments

  • int x - First argument.
  • int y - Second argument.

Return value

The rounded up quotient of two arguments that satisfies the following condition: y * z >= x.
Last update: 2021-04-30
Build: ()