Classes | Macros | Functions | Variables
b2_math.h File Reference
#include <math.h>
#include "b2_api.h"
#include "b2_settings.h"
Include dependency graph for b2_math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  b2Mat22
 A 2-by-2 matrix. Stored in column-major order. More...
 
struct  b2Mat33
 A 3-by-3 matrix. Stored in column-major order. More...
 
struct  b2Rot
 Rotation. More...
 
struct  b2Sweep
 
struct  b2Transform
 
struct  b2Vec2
 A 2D column vector. More...
 
struct  b2Vec3
 A 2D column vector with 3 elements. More...
 

Macros

#define b2Atan2(y, x)   atan2f(y, x)
 
#define b2Sqrt(x)   sqrtf(x)
 

Functions

template<typename T >
b2Abs (T a)
 
b2Vec2 b2Abs (const b2Vec2 &a)
 
b2Mat22 b2Abs (const b2Mat22 &A)
 
template<typename T >
b2Clamp (T a, T low, T high)
 
b2Vec2 b2Clamp (const b2Vec2 &a, const b2Vec2 &low, const b2Vec2 &high)
 
float b2Cross (const b2Vec2 &a, const b2Vec2 &b)
 Perform the cross product on two vectors. In 2D this produces a scalar. More...
 
b2Vec2 b2Cross (const b2Vec2 &a, float s)
 
b2Vec2 b2Cross (float s, const b2Vec2 &a)
 
b2Vec3 b2Cross (const b2Vec3 &a, const b2Vec3 &b)
 Perform the cross product on two vectors. More...
 
float b2Distance (const b2Vec2 &a, const b2Vec2 &b)
 
float b2DistanceSquared (const b2Vec2 &a, const b2Vec2 &b)
 
float b2Dot (const b2Vec2 &a, const b2Vec2 &b)
 Perform the dot product on two vectors. More...
 
float b2Dot (const b2Vec3 &a, const b2Vec3 &b)
 Perform the dot product on two vectors. More...
 
bool b2IsPowerOfTwo (uint32 x)
 
bool b2IsValid (float x)
 This function is used to ensure that a floating point number is not a NaN or infinity. More...
 
template<typename T >
b2Max (T a, T b)
 
b2Vec2 b2Max (const b2Vec2 &a, const b2Vec2 &b)
 
template<typename T >
b2Min (T a, T b)
 
b2Vec2 b2Min (const b2Vec2 &a, const b2Vec2 &b)
 
b2Vec2 b2Mul (const b2Mat22 &A, const b2Vec2 &v)
 
b2Mat22 b2Mul (const b2Mat22 &A, const b2Mat22 &B)
 
b2Vec3 b2Mul (const b2Mat33 &A, const b2Vec3 &v)
 Multiply a matrix times a vector. More...
 
b2Rot b2Mul (const b2Rot &q, const b2Rot &r)
 Multiply two rotations: q * r. More...
 
b2Vec2 b2Mul (const b2Rot &q, const b2Vec2 &v)
 Rotate a vector. More...
 
b2Vec2 b2Mul (const b2Transform &T, const b2Vec2 &v)
 
b2Transform b2Mul (const b2Transform &A, const b2Transform &B)
 
b2Vec2 b2Mul22 (const b2Mat33 &A, const b2Vec2 &v)
 Multiply a matrix times a vector. More...
 
b2Vec2 b2MulT (const b2Mat22 &A, const b2Vec2 &v)
 
b2Mat22 b2MulT (const b2Mat22 &A, const b2Mat22 &B)
 
b2Rot b2MulT (const b2Rot &q, const b2Rot &r)
 Transpose multiply two rotations: qT * r. More...
 
b2Vec2 b2MulT (const b2Rot &q, const b2Vec2 &v)
 Inverse rotate a vector. More...
 
b2Vec2 b2MulT (const b2Transform &T, const b2Vec2 &v)
 
b2Transform b2MulT (const b2Transform &A, const b2Transform &B)
 
uint32 b2NextPowerOfTwo (uint32 x)
 
template<typename T >
void b2Swap (T &a, T &b)
 
bool operator!= (const b2Vec2 &a, const b2Vec2 &b)
 
b2Vec2 operator* (float s, const b2Vec2 &a)
 
b2Vec3 operator* (float s, const b2Vec3 &a)
 
b2Vec2 operator+ (const b2Vec2 &a, const b2Vec2 &b)
 Add two vectors component-wise. More...
 
b2Vec3 operator+ (const b2Vec3 &a, const b2Vec3 &b)
 Add two vectors component-wise. More...
 
b2Mat22 operator+ (const b2Mat22 &A, const b2Mat22 &B)
 
b2Vec2 operator- (const b2Vec2 &a, const b2Vec2 &b)
 Subtract two vectors component-wise. More...
 
b2Vec3 operator- (const b2Vec3 &a, const b2Vec3 &b)
 Subtract two vectors component-wise. More...
 
bool operator== (const b2Vec2 &a, const b2Vec2 &b)
 

Variables

B2_API const b2Vec2 b2Vec2_zero
 Useful constant. More...
 

Macro Definition Documentation

◆ b2Atan2

#define b2Atan2 (   y,
 
)    atan2f(y, x)

Definition at line 38 of file b2_math.h.

◆ b2Sqrt

#define b2Sqrt (   x)    sqrtf(x)

Definition at line 37 of file b2_math.h.

Function Documentation

◆ b2Abs() [1/3]

template<typename T >
T b2Abs ( a)
inline

Definition at line 610 of file b2_math.h.

◆ b2Abs() [2/3]

b2Vec2 b2Abs ( const b2Vec2 a)
inline

Definition at line 615 of file b2_math.h.

◆ b2Abs() [3/3]

b2Mat22 b2Abs ( const b2Mat22 A)
inline

Definition at line 620 of file b2_math.h.

◆ b2Clamp() [1/2]

template<typename T >
T b2Clamp ( a,
low,
high 
)
inline

Definition at line 648 of file b2_math.h.

◆ b2Clamp() [2/2]

b2Vec2 b2Clamp ( const b2Vec2 a,
const b2Vec2 low,
const b2Vec2 high 
)
inline

Definition at line 653 of file b2_math.h.

◆ b2Cross() [1/4]

float b2Cross ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Perform the cross product on two vectors. In 2D this produces a scalar.

Definition at line 401 of file b2_math.h.

◆ b2Cross() [2/4]

b2Vec2 b2Cross ( const b2Vec2 a,
float  s 
)
inline

Perform the cross product on a vector and a scalar. In 2D this produces a vector.

Definition at line 408 of file b2_math.h.

◆ b2Cross() [3/4]

b2Vec2 b2Cross ( float  s,
const b2Vec2 a 
)
inline

Perform the cross product on a scalar and a vector. In 2D this produces a vector.

Definition at line 415 of file b2_math.h.

◆ b2Cross() [4/4]

b2Vec3 b2Cross ( const b2Vec3 a,
const b2Vec3 b 
)
inline

Perform the cross product on two vectors.

Definition at line 497 of file b2_math.h.

◆ b2Distance()

float b2Distance ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Definition at line 461 of file b2_math.h.

◆ b2DistanceSquared()

float b2DistanceSquared ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Definition at line 467 of file b2_math.h.

◆ b2Dot() [1/2]

float b2Dot ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Perform the dot product on two vectors.

Definition at line 395 of file b2_math.h.

◆ b2Dot() [2/2]

float b2Dot ( const b2Vec3 a,
const b2Vec3 b 
)
inline

Perform the dot product on two vectors.

Definition at line 491 of file b2_math.h.

◆ b2IsPowerOfTwo()

bool b2IsPowerOfTwo ( uint32  x)
inline

Definition at line 680 of file b2_math.h.

◆ b2IsValid()

bool b2IsValid ( float  x)
inline

This function is used to ensure that a floating point number is not a NaN or infinity.

Definition at line 32 of file b2_math.h.

◆ b2Max() [1/2]

template<typename T >
T b2Max ( a,
b 
)
inline

Definition at line 637 of file b2_math.h.

◆ b2Max() [2/2]

b2Vec2 b2Max ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Definition at line 642 of file b2_math.h.

◆ b2Min() [1/2]

template<typename T >
T b2Min ( a,
b 
)
inline

Definition at line 626 of file b2_math.h.

◆ b2Min() [2/2]

b2Vec2 b2Min ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Definition at line 631 of file b2_math.h.

◆ b2Mul() [1/7]

b2Vec2 b2Mul ( const b2Mat22 A,
const b2Vec2 v 
)
inline

Multiply a matrix times a vector. If a rotation matrix is provided, then this transforms the vector from one frame to another.

Definition at line 422 of file b2_math.h.

◆ b2Mul() [2/7]

b2Mat22 b2Mul ( const b2Mat22 A,
const b2Mat22 B 
)
inline

Definition at line 508 of file b2_math.h.

◆ b2Mul() [3/7]

b2Vec3 b2Mul ( const b2Mat33 A,
const b2Vec3 v 
)
inline

Multiply a matrix times a vector.

Definition at line 522 of file b2_math.h.

◆ b2Mul() [4/7]

b2Rot b2Mul ( const b2Rot q,
const b2Rot r 
)
inline

Multiply two rotations: q * r.

Definition at line 534 of file b2_math.h.

◆ b2Mul() [5/7]

b2Vec2 b2Mul ( const b2Rot q,
const b2Vec2 v 
)
inline

Rotate a vector.

Definition at line 560 of file b2_math.h.

◆ b2Mul() [6/7]

b2Vec2 b2Mul ( const b2Transform T,
const b2Vec2 v 
)
inline

Definition at line 571 of file b2_math.h.

◆ b2Mul() [7/7]

b2Transform b2Mul ( const b2Transform A,
const b2Transform B 
)
inline

Definition at line 591 of file b2_math.h.

◆ b2Mul22()

b2Vec2 b2Mul22 ( const b2Mat33 A,
const b2Vec2 v 
)
inline

Multiply a matrix times a vector.

Definition at line 528 of file b2_math.h.

◆ b2MulT() [1/6]

b2Vec2 b2MulT ( const b2Mat22 A,
const b2Vec2 v 
)
inline

Multiply a matrix transpose times a vector. If a rotation matrix is provided, then this transforms the vector from one frame to another (inverse transform).

Definition at line 429 of file b2_math.h.

◆ b2MulT() [2/6]

b2Mat22 b2MulT ( const b2Mat22 A,
const b2Mat22 B 
)
inline

Definition at line 514 of file b2_math.h.

◆ b2MulT() [3/6]

b2Rot b2MulT ( const b2Rot q,
const b2Rot r 
)
inline

Transpose multiply two rotations: qT * r.

Definition at line 547 of file b2_math.h.

◆ b2MulT() [4/6]

b2Vec2 b2MulT ( const b2Rot q,
const b2Vec2 v 
)
inline

Inverse rotate a vector.

Definition at line 566 of file b2_math.h.

◆ b2MulT() [5/6]

b2Vec2 b2MulT ( const b2Transform T,
const b2Vec2 v 
)
inline

Definition at line 579 of file b2_math.h.

◆ b2MulT() [6/6]

b2Transform b2MulT ( const b2Transform A,
const b2Transform B 
)
inline

Definition at line 601 of file b2_math.h.

◆ b2NextPowerOfTwo()

uint32 b2NextPowerOfTwo ( uint32  x)
inline

"Next Largest Power of 2 Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with the same most significant 1 as x, but all 1's below it. Adding 1 to that value yields the next largest power of 2. For a 32-bit value:"

Definition at line 670 of file b2_math.h.

◆ b2Swap()

template<typename T >
void b2Swap ( T &  a,
T &  b 
)
inline

Definition at line 658 of file b2_math.h.

◆ operator!=()

bool operator!= ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Definition at line 456 of file b2_math.h.

◆ operator*() [1/2]

b2Vec2 operator* ( float  s,
const b2Vec2 a 
)
inline

Definition at line 446 of file b2_math.h.

◆ operator*() [2/2]

b2Vec3 operator* ( float  s,
const b2Vec3 a 
)
inline

Definition at line 473 of file b2_math.h.

◆ operator+() [1/3]

b2Vec2 operator+ ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Add two vectors component-wise.

Definition at line 435 of file b2_math.h.

◆ operator+() [2/3]

b2Vec3 operator+ ( const b2Vec3 a,
const b2Vec3 b 
)
inline

Add two vectors component-wise.

Definition at line 479 of file b2_math.h.

◆ operator+() [3/3]

b2Mat22 operator+ ( const b2Mat22 A,
const b2Mat22 B 
)
inline

Definition at line 502 of file b2_math.h.

◆ operator-() [1/2]

b2Vec2 operator- ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Subtract two vectors component-wise.

Definition at line 441 of file b2_math.h.

◆ operator-() [2/2]

b2Vec3 operator- ( const b2Vec3 a,
const b2Vec3 b 
)
inline

Subtract two vectors component-wise.

Definition at line 485 of file b2_math.h.

◆ operator==()

bool operator== ( const b2Vec2 a,
const b2Vec2 b 
)
inline

Definition at line 451 of file b2_math.h.

Variable Documentation

◆ b2Vec2_zero

B2_API const b2Vec2 b2Vec2_zero

Useful constant.



mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:22