Crate nalgebra

source ·
Expand description

§nalgebra

nalgebra is a linear algebra library written for Rust targeting:

  • General-purpose linear algebra (still lacks a lot of features…)
  • Real-time computer graphics.
  • Real-time computer physics.

§Using nalgebra

You will need the last stable build of the rust compiler and the official package manager: cargo.

Simply add the following to your Cargo.toml file:

[dependencies]
// TODO: replace the * by the latest version.
nalgebra = "*"

Most useful functionalities of nalgebra are grouped in the root module nalgebra::.

However, the recommended way to use nalgebra is to import types and traits explicitly, and call free-functions using the na:: prefix:

#[macro_use]
extern crate approx; // For the macro assert_relative_eq!
extern crate nalgebra as na;
use na::{Vector3, Rotation3};

fn main() {
    let axis  = Vector3::x_axis();
    let angle = 1.57;
    let b     = Rotation3::from_axis_angle(&axis, angle);

    assert_relative_eq!(b.axis().unwrap(), axis);
    assert_relative_eq!(b.angle(), angle);
}

§Features

nalgebra is meant to be a general-purpose, low-dimensional, linear algebra library, with an optimized set of tools for computer graphics and physics. Those features include:

Re-exports§

Modules§

  • [Reexported at the root of this crate.] Data structures for vector and matrix computations.
  • [Reexported at the root of this crate.] Data structures for points and usual transformations (rotations, isometries, etc.)
  • [Reexported at the root of this crate.] Factorization of real matrices.

Macros§

  • Construct a dynamic matrix directly from data.
  • Construct a dynamic column vector directly from data.
  • Construct a fixed-size matrix directly from data.
  • Construct a fixed-size point directly from data.
  • Construct a new matrix by stacking matrices in a block matrix.
  • Construct a fixed-size column vector directly from data.

Structs§

  • A complex number in Cartesian form.

Traits§

  • Trait alias for Add and AddAssign with result of type Self.
  • Trait alias for Div and DivAssign with result of type Self.
  • Trait alias for Mul and MulAssign with result of type Self.
  • Trait alias for Sub and SubAssign with result of type Self.
  • Trait shared by all complex fields and its subfields (like real numbers).
  • Trait implemented by fields, i.e., complex numbers and floats.
  • Trait shared by all reals.
  • Lane-wise generalization of bool for SIMD booleans.
  • Lane-wise generalisation of ComplexField for SIMD complex fields.
  • Lane-wise generalization of the standard PartialOrd for SIMD values.
  • Lanewise generalization of RealField for SIMD reals.
  • Base trait for every SIMD types.

Functions§

  • absDeprecated
    The absolute value of a.
  • The center of two points.
  • Returns a reference to the input value clamped to the interval [min, max].
  • Converts an object from one type to an equivalent or more general one.
  • Converts an object from one type to an equivalent or more general one.
  • Use with care! Same as try_convert() but without any property checks.
  • Use with care! Same as try_convert() but without any property checks.
  • The distance between two points.
  • The squared distance between two points.
  • infDeprecated
    Returns the infimum of a and b.
  • inf_supDeprecated
    Returns simultaneously the infimum and supremum of a and b.
  • Indicates if try_convert() will succeed without actually performing the conversion.
  • Same as cmp::max.
  • Same as cmp::min.
  • Gets the multiplicative identity element.
  • Clamp value between min and max. Returns None if value is not comparable to min or max.
  • Compare a and b using a partial ordering relation.
  • Returns true iff a and b are comparable and a >= b.
  • Returns true iff a and b are comparable and a > b.
  • Returns true iff a and b are comparable and a <= b.
  • Returns true iff a and b are comparable and a < b.
  • Return the maximum of a and b if they are comparable.
  • Return the minimum of a and b if they are comparable.
  • Sorts two values in increasing order using a partial ordering.
  • supDeprecated
    Returns the supremum of a and b.
  • Attempts to convert an object to a more specific one.
  • Attempts to convert an object to a more specific one.
  • Wraps val into the range [min, max] using modular arithmetics.
  • Gets the additive identity element.