nalgebra/nalgebra-glm/src/gtc/matrix_access.rs
Bruce Mitchener 136a565579 docs: Use intradoc links rather than HTML.
This fixes almost all HTML links to be intradoc links that Rust
can verify during `cargo doc`. This will help prevent future
broken links.
2023-08-06 22:34:40 +07:00

66 lines
1.3 KiB
Rust

use na::Scalar;
use crate::aliases::{TMat, TVec};
/// The `index`-th column of the matrix `m`.
///
/// # See also:
///
/// * [`row()`]
/// * [`set_column()`]
/// * [`set_row()`]
pub fn column<T: Scalar, const R: usize, const C: usize>(
m: &TMat<T, R, C>,
index: usize,
) -> TVec<T, R> {
m.column(index).into_owned()
}
/// Sets to `x` the `index`-th column of the matrix `m`.
///
/// # See also:
///
/// * [`column()`]
/// * [`row()`]
/// * [`set_row()`]
pub fn set_column<T: Scalar, const R: usize, const C: usize>(
m: &TMat<T, R, C>,
index: usize,
x: &TVec<T, R>,
) -> TMat<T, R, C> {
let mut res = m.clone();
res.set_column(index, x);
res
}
/// The `index`-th row of the matrix `m`.
///
/// # See also:
///
/// * [`column()`]
/// * [`set_column()`]
/// * [`set_row()`]
pub fn row<T: Scalar, const R: usize, const C: usize>(
m: &TMat<T, R, C>,
index: usize,
) -> TVec<T, C> {
m.row(index).into_owned().transpose()
}
/// Sets to `x` the `index`-th row of the matrix `m`.
///
/// # See also:
///
/// * [`column()`]
/// * [`row()`]
/// * [`set_column()`]
pub fn set_row<T: Scalar, const R: usize, const C: usize>(
m: &TMat<T, R, C>,
index: usize,
x: &TVec<T, C>,
) -> TMat<T, R, C> {
let mut res = m.clone();
res.set_row(index, &x.transpose());
res
}