Struct mathf::matrix::Matrix2x2[][src]

pub struct Matrix2x2 {
    pub r1: Vector2,
    pub r2: Vector2,
}
Expand description

Implements a matrix 2 x 2

Fields

r1: Vector2r2: Vector2

Implementations

Identity Matrrix NxN, where all elements Uij that i = j are 1

// | 1 0 |
// | 0 1 |

Matrix determinant

//                | 4 -3 |
// let matrix =   | 0  2 |

// matrix.det() = 2
use mathf::matrix::{Matrix2x2};

let matrix = Matrix2x2::new_idx(4.0, -3.0, 0.0, 2.0);
assert_eq!(matrix.det(), 8f32);

Transforms a MatrixNxN into a Vec<Vec> by row

//                | 4 -3 |`
// let matrix =   | 0  2 |`
// matrix.det() = 2
use mathf::matrix::{Matrix2x2};

let matrix = Matrix2x2::new_idx(4.0, -3.0, 0.0, 2.0);
assert_eq!(matrix.vectorize(), vec![
   vec![4.0, -3.0], vec![0.0, 2.0]    
]);

Same as determinant for Matrix 2x2

Transpose of Matrix NxN. Transpose switches rows and columns

Matrix inverse

//                | 4 7 |
// let matrix =   | 2 6 |
//
//                             |  6 -7 |
// let matrix_inverse =  1/10  | -2  4 |
use mathf::matrix::{Matrix2x2};

let matrix = Matrix2x2::new_idx(4.0, 7.0, 2.0, 6.0);
let matrix_inverse = Matrix2x2::new_idx(0.6, -0.7, -0.2, 0.4);
assert_eq!(matrix.inverse(0.001).unwrap(), matrix_inverse);

A matrix is orthogonal if and only if transpose(A) == inverse(A)

// | a 0 |
// | 0 a |

Creates a new Matrix2x2 from 2 vector2 rows

Creates a new Matrix2x2 from 4 indexed floats

2D rotation Matrix by angle teta (radians) For matrix 2x2:

// P′= | cosθ − sinθ | P
//     | sinθ + cosθ |

Trait Implementations

Implements the &Matrix 2x2 ‘+’ trait

The resulting type after applying the + operator.

Implements the Matrix 2x2 ‘+’ trait

The resulting type after applying the + operator.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Implements the Matrix 2x2 ‘/’ trait for Matrix2x2 / f32 so that (identity / value).det() == valueˆ2.

The resulting type after applying the / operator.

Implements the Matrix 2x2 ‘/’ trait for &Matrix2x2 / f32 so that (identity / value).det() == valueˆ2.

The resulting type after applying the / operator.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Implements the &Matrix 2x2 ‘*’ trait for &Matrix2x2 * f32 so that (value * identity).det() == valueˆ2 and ßM == Mߘ.

The resulting type after applying the * operator.

Implements the transform matrix of a vector 2 into another vector 2. The order should be matrix * &point because of 2x2 * 2x1 = 2x1

The resulting type after applying the * operator.

Implements the transform matrix of a point 2 into another point 2. The order should be matrix * point because of 2x2 * 2x1 = 2x1

The resulting type after applying the * operator.

Implements the transform matrix of a vector 2 into another vector 2. The order should be matrix * &vector because of 2x2 * 2x1 = 2x1

The resulting type after applying the * operator.

Implements the transform matrix of a vector 2 into another vector 2. The order should be matrix * vector because of 2x2 * 2x1 = 2x1

The resulting type after applying the * operator.

Implements the Matrix 2x2 ‘*’ trait for Matrix2x2 * f32 so that (value * identity).det() == valueˆ2 and ßM == Mߘ.

The resulting type after applying the * operator.

Implements the Matrix 2x2 ‘*’ trait for Matrix2x2 * Matrix2x2

The resulting type after applying the * operator.

Implements the transform matrix of a vector 2 into another vector 2. The order should be matrix * vector because of 2x2 * 2x1 = 2x1

The resulting type after applying the * operator.

Implements the Matrix 2x2 ‘*’ trait for Matrix2x2 * f32 so that (identity * value).det() == valueˆ2.

The resulting type after applying the * operator.

Implements the &Matrix 2x2 ‘*’ trait for &Matrix2x2 * f32 so that (identity * value).det() == valueˆ2.

The resulting type after applying the * operator.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.