srp
software rendering pipeline
Loading...
Searching...
No Matches

Matrix API, only included if you define SRP_INCLUDE_MAT More...

Collaboration diagram for Matrix:

Classes

struct  mat4
 
typedef struct mat4 mat4
 
typedef struct mat4d mat4d
 
vec4d mat4dGetColumn (const mat4d *a, uint8_t index)
 
void mat4dSetColumn (mat4d *a, vec4d column, uint8_t index)
 
vec4d mat4dMultiplyVec4d (const mat4d *a, vec4d b)
 
mat4d mat4dMultiplyMat4d (const mat4d *a, const mat4d *b)
 
mat4d mat4dConstructIdentity ()
 
mat4d mat4dConstructScale (double x, double y, double z)
 
mat4d mat4dConstructTranslate (double x, double y, double z)
 
mat4d mat4dConstructRotate (double x, double y, double z)
 
mat4d mat4dConstructTRS (double transX, double transY, double transZ, double rotataionX, double rotataionY, double rotataionZ, double scaleX, double scaleY, double scaleZ)
 
mat4d mat4dConstructView (double cameraX, double cameraY, double cameraZ, double rotataionX, double rotataionY, double rotataionZ, double scaleX, double scaleY, double scaleZ)
 
mat4d mat4dConstructOrthogonalProjection (double x_min, double x_max, double y_min, double y_max, double z_min, double z_max)
 
mat4d mat4dConstructPerspectiveProjection (double x_min_near, double x_max_near, double y_min_near, double y_max_near, double z_near, double z_far)
 

Detailed Description

Matrix API, only included if you define SRP_INCLUDE_MAT

Typedef Documentation

◆ mat4

typedef struct mat4 mat4

Represents a 4x4 matrix of floats, stores data in row-major order

◆ mat4d

typedef struct mat4d mat4d

Represents a 4x4 matrix of doubles, stores data in row-major order

Function Documentation

◆ mat4dConstructIdentity()

mat4d mat4dConstructIdentity ( )

Construct a 4x4 identity matrix

Returns
4x4 identity matrix

◆ mat4dConstructOrthogonalProjection()

mat4d mat4dConstructOrthogonalProjection ( double  x_min,
double  x_max,
double  y_min,
double  y_max,
double  z_min,
double  z_max 
)

Construct a 4x4 orthogonal projection matrix. The orthogonal projection matrix transforms arbitrary rectangular parallelepiped (defined by 2 points: "min" and "max" ones) into an NDC cube, so it can be drawn in screen space

Parameters
x_min,y_min,z_minCoordinates of the "min" point defining a rectangular parallelepiped
x_max,y_max,z_maxCoordinates of the "max" point defining a rectangular parallelepiped
Returns
Orthogonal projection matrix

◆ mat4dConstructPerspectiveProjection()

mat4d mat4dConstructPerspectiveProjection ( double  x_min_near,
double  x_max_near,
double  y_min_near,
double  y_max_near,
double  z_near,
double  z_far 
)

Construct a 4x4 perspective projection matrix. The perspective projection matrix transforms the perspective frustum (defined by the distance to near and far planes and by "min" and "max" points on the near plane) to a unit cube, so it can be drawn in screen space

Parameters
x_min_near,x_max_nearMinimum and maximum X values on the near plane
y_min_near,y_max_nearMinimum and maximum Y on the near plane
z_near,z_farDistance to the near and far planes
Returns
Perspective projection matrix
Todo:
Avoid matmul here?

◆ mat4dConstructRotate()

mat4d mat4dConstructRotate ( double  x,
double  y,
double  z 
)

Construct a 4x4 matrix that rotates the points

Parameters
x,y,zAngle (in radians) by which the points are rotated around X, Y, Z axis respectively
Returns
Rotation matrix

◆ mat4dConstructScale()

mat4d mat4dConstructScale ( double  x,
double  y,
double  z 
)

Construct a 4x4 matrix that scales the X, Y and Z dimensions

Parameters
x,y,zScaling coefficients for X, Y, Z dimensions respectively
Returns
Scale matrix

◆ mat4dConstructTranslate()

mat4d mat4dConstructTranslate ( double  x,
double  y,
double  z 
)

Construct a 4x4 matrix that translates the points

Parameters
x,y,zTranslating coefficient for X, Y, Z dimensions respectively
Returns
Translation matrix

◆ mat4dConstructTRS()

mat4d mat4dConstructTRS ( double  transX,
double  transY,
double  transZ,
double  rotataionX,
double  rotataionY,
double  rotataionZ,
double  scaleX,
double  scaleY,
double  scaleZ 
)

Construct a 4x4 matrix that translates, rotates the points and scales the X, Y, and Z dimenstions

See also
mat4dConstructScale() mat4dConstructTranslate() mat4dConstructRotate()
Returns
TRS matrix

◆ mat4dConstructView()

mat4d mat4dConstructView ( double  cameraX,
double  cameraY,
double  cameraZ,
double  rotataionX,
double  rotataionY,
double  rotataionZ,
double  scaleX,
double  scaleY,
double  scaleZ 
)

Construct a 4x4 view matrix

Parameters
cameraX,cameraY,cameraZCamera position
rotationX,rotationY,rotationZCamera rotation along each dimension
scaleX,scaleY,scaleZCamera "zoom" along each dimension
Returns
View matrix

◆ mat4dGetColumn()

vec4d mat4dGetColumn ( const mat4d a,
uint8_t  index 
)

Get the indexth column of the matrix A

Parameters
aPointer to a matrix A
indexIndex of a column to get
Returns
indexth column of the matrix A

◆ mat4dMultiplyMat4d()

mat4d mat4dMultiplyMat4d ( const mat4d a,
const mat4d b 
)

Multiply two 4x4 matrices

Parameters
aPointer to a matrix A
bPointer to a matrix B
Returns
The product A*B

◆ mat4dMultiplyVec4d()

vec4d mat4dMultiplyVec4d ( const mat4d a,
vec4d  b 
)

Multiply mat4d by vec4d

Parameters
aPointer to a matrix A
bVector B
Returns
The product A*B

◆ mat4dSetColumn()

void mat4dSetColumn ( mat4d a,
vec4d  column,
uint8_t  index 
)

Set the indexth column of the *a matrix to column

Parameters
aPointer to a matrix
columnA new column
indexIndex of a column to modify