Skip to content

Math

Math libraries and utilities

Types

Name Description
BarycentricCoordinates Represents barycentric coordinates between a point and 3 vertices of a triangle.
BeizerCurveControlPoints A structure containing control points for a Bezier curve.
BoxShape A box shape, defined by a width, an height, and a depth.
BoxZone A Zone built with an inner BoxShape and an outer BoxShape.
CapsuleShape A capsule shape, defined by a radius and an height.
CapsuleZone A Zone built with an inner CapsuleShape and an outer CapsuleShape.
CartesianCoordinateSystem A class representing a cartesian coordinate system.
ConeShape A cone shape, defined by a radius and an height.
ConeZone A Zone built with an inner ConeShape and an outer ConeShape.
Curve A Curve which describe the variation of a value (on the Y-axis) according to another (on the X-axis).
CurvePart A segment of a Curve.
CurvePoint A single point in a Curve.
Edge Represents an edge.
Face Represents a triangulated face.
Orientation Represents an orientation in 3D space.
Shape A geometrical closed 3D shape.
SphereShape A sphere shape, defined by a radius.
SphereZone A Zone built with an inner SphereShape and an outer SphereShape.
SphericalPosition Spherical coordinates representation.
Zone A tuple of shapes that represents a zone in the world.

Macros

Name Description
AM_BETWEEN Checks if a value is between a and b.
AM_CLAMP Clamps a value between a and b.

Functions

Name Description
AmDitherReal32 Generates a random number between ditherMin and ditherMax.
AmFloatToFixedPoint Converts a 32-bit floating-point audio sample to a fixed-point representation.
AmInt16ToReal32 Converts a 16-bit signed integer audio sample to a 32-bit floating-point representation.
AmInt32ToReal32 Converts a 32-bit signed integer audio sample to a 32-bit floating-point representation.
AmReal32ToInt16 Converts a 32-bit floating-point audio sample to a 16-bit signed integer representation.
CatmullRom Computes the Catmull-Rom interpolation value at a given time t between four points.
ComputeDopplerFactor Computes the Doppler factor for a sound source at a given location.
FindGCD Finds the greatest common divisor (GCD) of two integers.
GetRelativeDirection Returns a direction vector relative to a given position and rotation.
IntegerPow Computes the value base^exp using the squared exponentiation method.
NextPowerOf2 Returns the next power of 2 of a given number.

Macro Details

AM_BETWEEN

#define AM_BETWEEN(v, a, b)

Checks if a value is between a and b.

Parameter v
The value to check
Parameter a
The minimum value
Parameter b
The maximum value
Return
true if the value is between a and b, false otherwise.

AM_CLAMP

#define AM_CLAMP(v, a, b)

Clamps a value between a and b.

Parameter v
The value to clamp
Parameter a
The minimum value
Parameter b
The maximum value
Return
The clamped value

Function Details

AmDitherReal32

inline AmReal32 AmDitherReal32(const AmReal32 ditherMin, const AmReal32 ditherMax)

Generates a random number between ditherMin and ditherMax.

Parameter ditherMin
The minimum value for the random number.
Parameter ditherMax
The maximum value for the random number.
Return
A random number between ditherMin and ditherMax.

AmFloatToFixedPoint

inline AmInt32 AmFloatToFixedPoint(const AmReal32 x)

Converts a 32-bit floating-point audio sample to a fixed-point representation.

Parameter x
The 32-bit floating-point audio sample to convert.
Return
The fixed-point representation of the input 32-bit floating-point audio sample.

AmInt16ToReal32

inline AmReal32 AmInt16ToReal32(const AmInt16 x)

Converts a 16-bit signed integer audio sample to a 32-bit floating-point representation.

Parameter x
The 16-bit signed integer audio sample to convert.
Return
The 32-bit floating-point representation of the input 16-bit signed integer audio sample.

Tip

For more accurate conversion, the SDK should be compiled with the AM_ACCURATE_CONVERSION macro defined.

AmInt32ToReal32

inline AmReal32 AmInt32ToReal32(const AmInt32 x)

Converts a 32-bit signed integer audio sample to a 32-bit floating-point representation.

Parameter x
The 32-bit signed integer audio sample to convert.
Return
The 32-bit floating-point representation of the input 32-bit signed integer audio sample.

Tip

For more accurate conversion, the SDK should be compiled with the AM_ACCURATE_CONVERSION macro defined.

AmReal32ToInt16

inline AmInt16 AmReal32ToInt16(const AmReal32 x, bool dithering = false)

Converts a 32-bit floating-point audio sample to a 16-bit signed integer representation.

Parameter x
The 32-bit floating-point audio sample to convert.
Parameter dithering
If true, adds a dithering noise to the output.
Return
The 16-bit signed integer representation of the input 32-bit floating-point audio sample.

Tip

For more accurate conversion, the SDK should be compiled with the AM_ACCURATE_CONVERSION macro defined.

CatmullRom

inline 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.

Parameter t
The time value between 0 and 1.
Parameter p0
The first point.
Parameter p1
The second point.
Parameter p2
The third point.
Parameter p3
The fourth point.
Return
The Catmull-Rom interpolation value at the given time t.

ComputeDopplerFactor

inline AmReal32 ComputeDopplerFactor( const AmVec3& locationDelta, const AmVec3& sourceVelocity, const AmVec3& listenerVelocity, const AmReal32 soundSpeed, const AmReal32 dopplerFactor)

Computes the Doppler factor for a sound source at a given location.

Parameter locationDelta
The distance vector from the listener to the sound source.
Parameter sourceVelocity
The velocity of the sound source.
Parameter listenerVelocity
The velocity of the listener.
Parameter soundSpeed
The speed of sound.
Parameter dopplerFactor
The Doppler factor.
Return
The computed Doppler factor.

FindGCD

inline AmInt64 FindGCD(AmInt64 a, AmInt64 b)

Finds the greatest common divisor (GCD) of two integers.

Parameter a
First integer.
Parameter b
Second integer.
Return
The greatest common divisor of a and b.

GetRelativeDirection

inline AmVec3 GetRelativeDirection(const AmVec3& originPosition, const AmQuat& originRotation, const AmVec3& position)

Returns a direction vector relative to a given position and rotation.

Parameter originPosition
Origin position of the direction.
Parameter originRotation
Origin rotation of the direction.
Parameter position
Target position of the direction.
Return
A relative direction vector (not normalized).

IntegerPow

template<typename T> inline T IntegerPow(T base, AmInt32 exp)

Computes the value base^exp using the squared exponentiation method.

Template parameter T
An integer type, a floating-point type, or a any other type where operator *= is defined.
Parameter base
Input of the power function.
Parameter exp
The exponent of the power function. Must be non-negative.
Return
The result of raising the base to the power of the exponent.

NextPowerOf2

template<typename T> inline T NextPowerOf2(const T& val)

Returns the next power of 2 of a given number.

Template parameter T
An integer type, a floating-point type, or a any other type where operator *= is defined.
Parameter val
The number.
Return
The next power of 2.