# Crate vecmath [−] [src]

A simple and generic library for vector math.

Notice that row major is mathematical standard, while OpenGL uses column major format. This library supports both formats, prefixing functions with 'row_' or 'col_'.

For row major affine transforms, use `Matrix2x3` (2D) and `Matrix3x4` (3D). For column major affine transforms, use `Matrix3x2` (2D) and `Matrix4x3` (3D).

If you are using `Matrix3` or `Matrix4`, then you need to pick either row or column major.

Notice that there are two kinds of transforms: Positions and vectors. The vector transforms ignores the translate component. For example, `row_mat2x3_transform_pos2` transforms a position. `row_mat2x3_transform_vec2` transforms a vector.

## Modules

 traits Various useful traits

## Functions

 col_mat2x3_row Returns a row vector of a column matrix. col_mat3_mul Multiplies two matrices. col_mat3_mul_col Computes column vector in column matrix product. col_mat3_row Returns a row vector of a column matrix. col_mat3_transform Transforms a 3D vector through a matrix. col_mat3_transform_pos2 Transforms a 2D position through column matrix. col_mat3_transform_vec2 Transforms a 2D vector through column matrix. col_mat3x2_mul Multiplies two matrices. col_mat3x2_mul_col Computes column vector in column matrix product. col_mat3x2_row Returns a row vector of a column matrix. col_mat3x2_transform_pos2 Transforms a 2D position through matrix. col_mat3x2_transform_vec2 Transforms a 2D vector through matrix. col_mat3x4_row Returns a row vector of a column matrix. col_mat4_mul Multiplies two matrices. col_mat4_mul_col Computes column vector in column matrix product. col_mat4_row Returns a row vector of a column matrix. col_mat4_transform Transforms a 4D vector through a matrix. col_mat4x3_mul Multiplies two matrices. col_mat4x3_mul_col Computes column vector in column matrix product. col_mat4x3_row Returns a column vector of a row matrix. col_mat4x3_transform_pos3 Transforms a 3D position through matrix. col_mat4x3_transform_vec3 Transforms a 3D vector through matrix. mat2x3_add Adds two matrices. mat2x3_cast Converts to another matrix type. mat2x3_det Computes the determinant of a matrix. mat2x3_id Constructs identity matrix. mat2x3_inv Computes the inverse of a 2x3 matrix. mat2x3_inv_det Computes inverse determinant of a 2x3 matrix. mat2x3_sub Subtracts 'b' from 'a'. mat2x3_transposed Constructs the transpose of a matrix. mat3_add Adds two matrices. mat3_cast Converts to another matrix type. mat3_det Computes the determinant of a matrix. mat3_id Constructs identity matrix. mat3_inv Computes the inverse of a 3x3 matrix. mat3_inv_det Computes inverse determinant of a 3x3 matrix. mat3_sub Subtracts 'b' from 'a'. mat3_transposed Constructs the transpose of a matrix. mat3x2_add Adds two matrices. mat3x2_cast Converts to another matrix type. mat3x2_det Computes the determinant of a matrix. mat3x2_id Constructs identity matrix. mat3x2_inv Computes the inverse of a 3x2 matrix. mat3x2_inv_det Computes inverse determinant of a 3x2 matrix. mat3x2_sub Subtracts 'b' from 'a'. mat3x2_transposed Constructs the transpose of a matrix. mat3x4_add Adds two matrices. mat3x4_cast Converts to another matrix type. mat3x4_det Computes the determinant of a matrix. mat3x4_id Constructs identity matrix. mat3x4_inv Computes the inverse of a 3x4 matrix. mat3x4_inv_det Computes inverse determinant of a 3x4 matrix. mat3x4_sub Subtracts 'b' from 'a'. mat3x4_transposed Constructs the transpose of a matrix. mat4_add Adds two matrices. mat4_cast Converts to another matrix type. mat4_det Computes the determinant of a 4x4 matrix. mat4_id Constructs identity matrix. mat4_inv Computes the inverse of a 4x4 matrix. mat4_inv_det Computes the inverse determinant of a 4x4 matrix. mat4_sub Subtracts 'b' from 'a'. mat4_transposed Constructs the transpose of a matrix. mat4x3_add Adds two matrices. mat4x3_cast Converts to another matrix type. mat4x3_det Computes the determinant of a matrix. mat4x3_id Constructs identity matrix. mat4x3_inv Computes the inverse of a 4x3 matrix. mat4x3_inv_det Computes inverse determinant of a 4x3 matrix. mat4x3_sub Subtracts 'b' from 'a'. mat4x3_transposed Constructs the transpose of a matrix. row_mat2x3_col Returns a column vector of a row matrix. row_mat2x3_mul Multiplies two matrices. row_mat2x3_mul_row Computes row vector in row matrix product. row_mat2x3_transform_pos2 Transforms a 2D position through matrix. row_mat2x3_transform_vec2 Transforms a 2D vector through matrix. row_mat3_col Returns a column vector of a row matrix. row_mat3_mul Multiplies two matrices. row_mat3_mul_row Computes row vector in row matrix product. row_mat3_transform Transforms a 3D vector through a matrix. row_mat3_transform_pos2 Transforms a 2D position through row matrix. row_mat3_transform_vec2 Transforms a 2D vector through row matrix. row_mat3x2_col Returns a column vector of a row matrix. row_mat3x4_col Returns a column vector of a row matrix. row_mat3x4_mul Multiplies two matrices. row_mat3x4_mul_row Computes row vector in row matrix product. row_mat3x4_transform_pos3 Transforms a 3D position through matrix. row_mat3x4_transform_vec3 Transforms a 3D vector through matrix. row_mat4_col Returns a column vector of a row matrix. row_mat4_mul Multiplies two matrices. row_mat4_mul_row Computes row vector in row matrix product. row_mat4_transform Transforms a 4D vector through a matrix. row_mat4x3_col Returns a column vector of a row matrix. vec2_add Adds two vectors. vec2_cast Converts to another vector type. vec2_cross Computes the cross product. vec2_dot Computes the dot product. vec2_inv_len Computes the inverse length of a vector. vec2_len Computes the length of vector. vec2_mul Multiplies two vectors component wise. vec2_neg Negates the vector. vec2_normalized Computes the normalized. vec2_normalized_sub Computes the normalized difference between two vectors. vec2_scale Multiplies the vector with a scalar. vec2_square_len Computes the square length of a vector. vec2_sub Subtracts 'b' from 'a'. vec3_add Adds two vectors. vec3_cast Converts to another vector type. vec3_cross Computes the cross product. vec3_dot Computes the dot product. vec3_dot_pos2 Computes transformed position component. vec3_dot_vec2 Computes transformed vector component. vec3_inv_len Computes the inverse length of a vector. vec3_len Computes the length of vector. vec3_mul Multiplies two vectors component wise. vec3_neg Negates the vector. vec3_normalized Computes the normalized. vec3_normalized_sub Computes the normalized difference between two vectors. vec3_scale Multiplies the vector with a scalar. vec3_square_len Computes the square length of a vector. vec3_sub Subtracts 'b' from 'a'. vec4_add Adds two vectors. vec4_cast Converts to another vector type. vec4_dot Computes the dot product. vec4_dot_pos3 Computes transformed position component. vec4_dot_vec3 Computes transformed vector component. vec4_inv_len Computes the inverse length of a vector. vec4_len Computes the length of vector. vec4_mul Multiplies two vectors component wise. vec4_neg Negates the vector. vec4_normalized Computes the normalized. vec4_normalized_sub Computes the normalized difference between two vectors. vec4_scale Multiplies the vector with a scalar. vec4_square_len Computes the square length of a vector. vec4_sub Subtracts 'b' from 'a'.

## Type Definitions

 Matrix3 A 3x3 matrix. Matrix4 A 4x4 matrix. Matrix2x3 A 2x3 matrix. Matrix3x2 A 3x2 matrix. Matrix3x4 A 3x4 matrix. Matrix4x3 A 4x3 matrix. Vector2 A 2D vector. Vector3 A 3D vector. Vector4 A 4D vector.