Group math¶
Math libraries and utilities.
Classes¶
| Type | Name |
|---|---|
| struct | SparkyStudios::Audio::Amplitude::BarycentricCoordinates Represents barycentric coordinates between a point and 3 vertices of a triangle. |
| struct | SparkyStudios::Audio::Amplitude::BezierCurveControlPoints A structure containing control points for a Bézier curve. |
| class | SparkyStudios::Audio::Amplitude::BoxShape A box shape, defined by a width, a height, and a depth. |
| class | SparkyStudios::Audio::Amplitude::BoxZone A Zone built with an innerBoxShape and an outerBoxShape . |
| class | SparkyStudios::Audio::Amplitude::CapsuleShape A capsule shape, defined by a radius and a height. |
| class | SparkyStudios::Audio::Amplitude::CapsuleZone A Zone built with an innerCapsuleShape and an outerCapsuleShape . |
| class | SparkyStudios::Audio::Amplitude::CartesianCoordinateSystem A class representing a cartesian coordinate system. |
| class | SparkyStudios::Audio::Amplitude::ConeShape A cone shape, defined by a radius and a height. |
| class | SparkyStudios::Audio::Amplitude::ConeZone A Zone built with an innerConeShape and an outerConeShape . |
| class | SparkyStudios::Audio::Amplitude::Curve A Curve that describes the variation of a value (on the Y-axis) according to another (on the X-axis). |
| class | SparkyStudios::Audio::Amplitude::CurvePart A segment of a Curve . |
| struct | SparkyStudios::Audio::Amplitude::CurvePoint A single point in a Curve . |
| struct | SparkyStudios::Audio::Amplitude::Edge Represents an edge. |
| struct | SparkyStudios::Audio::Amplitude::Face Represents a triangulated face. |
| struct | SparkyStudios::Audio::Amplitude::Orientation Represents an orientation in 3D space. |
| class | SparkyStudios::Audio::Amplitude::Shape A geometrical closed 3D shape. |
| class | SparkyStudios::Audio::Amplitude::SphereShape A sphere shape, defined by a radius. |
| class | SparkyStudios::Audio::Amplitude::SphereZone A Zone built with an innerSphereShape and an outerSphereShape . |
| struct | SparkyStudios::Audio::Amplitude::SphericalPosition Spherical coordinates representation. |
| class | SparkyStudios::Audio::Amplitude::Zone A tuple of shapes that represents a zone in the world. |
Public Types¶
| Type | Name |
|---|---|
| union | SparkyStudios::Audio::Amplitude::Triangle Represent a triangle geometry. |
| typedef union SparkyStudios::Audio::Amplitude::Triangle | Triangle Represent a triangle geometry. |
Public Attributes¶
| Type | Name |
|---|---|
| AmMatrix3 | kMatrix3Identity = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }An identity matrix in 3D space. |
| AmMatrix4 | kMatrix4Identity = /* multi line expression */An identity matrix in 4D space. |
| AmVector2 | kVector2One = { 1.0f, 1.0f }A unit vector in 2D space. |
| AmVector2 | kVector2UnitX = { 1.0f, 0.0f }A unit vector along the X-axis in 2D space. |
| AmVector2 | kVector2UnitY = { 0.0f, 1.0f }A unit vector along the Y-axis in 2D space. |
| AmVector2 | kVector2Zero = { 0.0f, 0.0f }A zero vector in 2D space. |
| AmVector3 | kVector3One = { 1.0f, 1.0f, 1.0f }A unit vector in 3D space. |
| AmVector3 | kVector3UnitX = { 1.0f, 0.0f, 0.0f }A unit vector along the X-axis in 3D space. |
| AmVector3 | kVector3UnitY = { 0.0f, 1.0f, 0.0f }A unit vector along the Y-axis in 3D space. |
| AmVector3 | kVector3UnitZ = { 0.0f, 0.0f, 1.0f }A unit vector along the Z-axis in 3D space. |
| AmVector3 | kVector3Zero = { 0.0f, 0.0f, 0.0f }A zero vector in 3D space. |
| AmVector4 | kVector4One = { 1.0f, 1.0f, 1.0f, 1.0f }A unit vector in 4D space. |
| AmVector4 | kVector4UnitW = { 0.0f, 0.0f, 0.0f, 1.0f }A unit vector along the W-axis in 4D space. |
| AmVector4 | kVector4UnitX = { 1.0f, 0.0f, 0.0f, 0.0f }A unit vector along the X-axis in 4D space. |
| AmVector4 | kVector4UnitY = { 0.0f, 1.0f, 0.0f, 0.0f }A unit vector along the Y-axis in 4D space. |
| AmVector4 | kVector4UnitZ = { 0.0f, 0.0f, 1.0f, 0.0f }A unit vector along the Z-axis in 4D space. |
| AmVector4 | kVector4Zero = { 0.0f, 0.0f, 0.0f, 0.0f }A zero vector in 4D space. |
Public Functions¶
| Type | Name |
|---|---|
| AmReal32 | AmDitherReal32 (const AmReal32 ditherMin, const AmReal32 ditherMax) Generates a random number between ditherMin andditherMax . |
| AmInt32 | AmFloatToFixedPoint (const AmReal32 x) Converts a 32-bit floating-point audio sample to a fixed-point representation. |
| AmReal32 | AmInt16ToReal32 (const AmInt16 x) Converts a 16-bit signed integer audio sample to a 32-bit floating-point representation. |
| AmReal32 | AmInt32ToReal32 (const AmInt32 x) Converts a 32-bit signed integer audio sample to a 32-bit floating-point representation. |
| AmInt16 | AmReal32ToInt16 (const AmReal32 x, bool dithering=false) Converts a 32-bit floating-point audio sample to a 16-bit signed integer representation. |
| AmReal32 | CatmullRom (const AmReal32 t, const AmReal32 p0, const AmReal32 p1, const AmReal32 p2, const AmReal32 p3) Computes the Catmull-Rom interpolation value at a given time t between four points. |
| AmInt64 | FindGCD (AmInt64 a, AmInt64 b) Finds the greatest common divisor (GCD) of two integers. |
| T | IntegerPow (T base, AmInt32 exp) Computes the value base^exp using the squared exponentiation method. |
| AmReal32 | InverseSquareRoot (AmReal32 x) Calculates the inverse square root of a number using Quake III's implementation. |
| AmReal32 | Lerp (const AmReal32 t, const AmReal32 p0, const AmReal32 p1) Calculates the linear interpolation value at a given time t between two points. |
| T | NextPowerOf2 (const T & val) Returns the next power of 2 of a given number. |
Macros¶
| Type | Name |
|---|---|
| define | AM_ABS (a) ((a) > 0 ? (a) : -(a))Gets the absolute version of a value. |
| define | AM_BETWEEN (v, a, b) ((v) >= [**AM\_MIN**](group__math.md#define-am_min)(a, b) && (v) <= [**AM\_MAX**](group__math.md#define-am_max)(a, b))Checks if a value is between a and b. |
| define | AM_CLAMP (v, a, b) (((v) < (a)) ? (a) : ((v) > (b)) ? (b) : (v))Clamps a value between a and b. |
| define | AM_CUBED (x) ((x) \* (x) \* (x))Compute the cube of a number. |
| define | AM_MAX (a, b) ((a) > (b) ? (a) : (b))Gets the maximum between two values. |
| define | AM_MIN (a, b) ((a) < (b) ? (a) : (b))Gets the minimum between two values. |
| define | AM_MOD (a, m) (((a) % (m)) >= 0 ? ((a) % (m)) : (((a) % (m)) + (m)))Compute modulo that always returns positive values. |
| define | AM_SQUARED (x) ((x) \* (x))Compute the square of a number. |
Public Types Documentation¶
Triangle
Represent a triangle geometry.
A triangle is a collection of three vertices oriented in a Clock-Wise (CW) manner.
Triangle
Represent a triangle geometry.
A triangle is a collection of three vertices oriented in a Clock-Wise (CW) manner.
Public Attributes Documentation¶
kMatrix3Identity
An identity matrix in 3D space.
This constant represents a 3x3 identity matrix, which is used to represent no transformation.
kMatrix4Identity
An identity matrix in 4D space.
This constant represents a 4x4 identity matrix, which is used to represent no transformation.
kVector2One
A unit vector in 2D space.
This constant represents a vector with all components set to one.
kVector2UnitX
A unit vector along the X-axis in 2D space.
This constant represents a basis vector pointing in the positive X direction.
kVector2UnitY
A unit vector along the Y-axis in 2D space.
This constant represents a basis vector pointing in the positive Y direction.
kVector2Zero
A zero vector in 2D space.
This constant represents a vector with all components set to zero.
kVector3One
A unit vector in 3D space.
This constant represents a vector with all components set to one.
kVector3UnitX
A unit vector along the X-axis in 3D space.
This constant represents a basis vector pointing in the positive X direction.
kVector3UnitY
A unit vector along the Y-axis in 3D space.
This constant represents a basis vector pointing in the positive Y direction.
kVector3UnitZ
A unit vector along the Z-axis in 3D space.
This constant represents a basis vector pointing in the positive Z direction.
kVector3Zero
A zero vector in 3D space.
This constant represents a vector with all components set to zero.
kVector4One
A unit vector in 4D space.
This constant represents a vector with all components set to one.
kVector4UnitW
A unit vector along the W-axis in 4D space.
This constant represents a basis vector pointing in the positive W direction.
kVector4UnitX
A unit vector along the X-axis in 4D space.
This constant represents a basis vector pointing in the positive X direction.
kVector4UnitY
A unit vector along the Y-axis in 4D space.
This constant represents a basis vector pointing in the positive Y direction.
kVector4UnitZ
A unit vector along the Z-axis in 4D space.
This constant represents a basis vector pointing in the positive Z direction.
kVector4Zero
A zero vector in 4D space.
This constant represents a vector with all components set to zero.
Public Functions Documentation¶
AmDitherReal32
Generates a random number between ditherMin andditherMax .
Parameters:
-
ditherMinThe minimum value for the random number. -
ditherMaxThe maximum value for the random number.
Returns:
A random number between ditherMin and ditherMax.
AmFloatToFixedPoint
Converts a 32-bit floating-point audio sample to a fixed-point representation.
Parameters:
-
xThe 32-bit floating-point audio sample to convert.
Returns:
The fixed-point representation of the input 32-bit floating-point audio sample.
AmInt16ToReal32
Converts a 16-bit signed integer audio sample to a 32-bit floating-point representation.
Parameters:
-
xThe 16-bit signed integer audio sample to convert.
Returns:
The 32-bit floating-point representation of the input 16-bit signed integer audio sample.
Note:
For more accurate conversion, the SDK should be compiled with the AM_ACCURATE_CONVERSION macro defined.
AmInt32ToReal32
Converts a 32-bit signed integer audio sample to a 32-bit floating-point representation.
Parameters:
-
xThe 32-bit signed integer audio sample to convert.
Returns:
The 32-bit floating-point representation of the input 32-bit signed integer audio sample.
Note:
For more accurate conversion, the SDK should be compiled with the AM_ACCURATE_CONVERSION macro defined.
AmReal32ToInt16
Converts a 32-bit floating-point audio sample to a 16-bit signed integer representation.
Parameters:
-
xThe 32-bit floating-point audio sample to convert. -
ditheringIftrue, adds a dithering noise to the output.
Returns:
The 16-bit signed integer representation of the input 32-bit floating-point audio sample.
Note:
For more accurate conversion, the SDK should be compiled with the AM_ACCURATE_CONVERSION macro defined.
CatmullRom
Computes the Catmull-Rom interpolation value at a given time t between four points.
inline AmReal32 CatmullRom (
const AmReal32 t,
const AmReal32 p0,
const AmReal32 p1,
const AmReal32 p2,
const AmReal32 p3
)
Parameters:
-
tThe time value between 0 and 1. -
p0The first point. -
p1The second point. -
p2The third point. -
p3The fourth point.
Returns:
The Catmull-Rom interpolation value at the given time t.
FindGCD
Finds the greatest common divisor (GCD) of two integers.
Parameters:
-
aFirst integer. -
bSecond integer.
Returns:
The greatest common divisor of a and b.
IntegerPow
Computes the value base^exp using the squared exponentiation method.
Template parameters:
TAn integer type, a floating-point type, or any other type where operator *= is defined.
Parameters:
-
baseInput of the power function. -
expThe exponent of the power function. Must be non-negative.
Returns:
The result of raising the base to the power of the exponent.
InverseSquareRoot
Calculates the inverse square root of a number using Quake III's implementation.
Parameters:
-
xThe number to calculate the inverse square root of.
Returns:
The inverse square root of the input number.
Lerp
Calculates the linear interpolation value at a given time t between two points.
Parameters:
-
tThe time value between 0 and 1. -
p0The first point. -
p1The second point.
Returns:
The linear interpolation value at the given time t.
NextPowerOf2
Returns the next power of 2 of a given number.
Template parameters:
TAn integer type, a floating-point type, or any other type where operator *= is defined.
Parameters:
-
valThe number.
Returns:
The next power of 2.
Macro Definition Documentation¶
AM_ABS
Gets the absolute version of a value.
Parameters:
aThe value.
Returns:
A positive number if a was negative.
AM_BETWEEN
Checks if a value is between a and b.
Parameters:
vThe value to checkaThe minimum valuebThe maximum value
Returns:
true if the value is between a and b, false otherwise.
AM_CLAMP
Clamps a value between a and b.
Parameters:
vThe value to clampaThe minimum valuebThe maximum value
Returns:
The clamped value
AM_CUBED
Compute the cube of a number.
Parameters:
xThe number to cube
Returns:
The cubed value.
AM_MAX
Gets the maximum between two values.
Parameters:
aThe first value.bThe second value.
Returns:
The highest value between a and b.
AM_MIN
Gets the minimum between two values.
Parameters:
aThe first valuebThe second value
Returns:
The lowest value between a and b.
AM_MOD
Compute modulo that always returns positive values.
Parameters:
aThe dividendmThe divisor
Returns:
The positive modulo result.
AM_SQUARED
Compute the square of a number.
Parameters:
xThe number to square
Returns:
The squared value.