[][src]Crate nalgebra

nalgebra

nalgebra is a linear algebra library written for Rust targeting:

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:

This example is not tested
[dependencies]
nalgebra = "0.18"

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 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);

    relative_eq!(b.axis().unwrap(), axis);
    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

pub use base as core;
pub use crate::base::*;
pub use crate::geometry::*;
pub use crate::linalg::*;

Modules

base

[Reexported at the root of this crate.] Data structures for vector and matrix computations.

geometry

[Reexported at the root of this crate.] Data structures for points and usual transformations (rotations, isometries, etc.)

linalg

[Reexported at the root of this crate.] Factorization of real matrices.

Structs

Complex

A complex number in Cartesian form.

Id

The universal identity element wrt. a given operator, usually noted Id with a context-dependent subscript.

Traits

ComplexField

Trait shared by all complex fields and its subfields (like real numbers).

RealDeprecated

The field of reals. This has been renamed to RealField.

RealField

Trait shared by all reals.

Functions

absDeprecated

The absolute value of a.

angleDeprecated

Computes the smallest angle between two vectors.

center

The center of two points.

clamp

Returns a reference to the input value clamped to the interval [min, max].

convert

Converts an object from one type to an equivalent or more general one.

convert_ref

Converts an object from one type to an equivalent or more general one.

convert_ref_unchecked

Use with care! Same as try_convert but without any property checks.

convert_unchecked

Use with care! Same as try_convert but without any property checks.

dimension

The dimension of the given algebraic entity seen as a vector space.

distance

The distance between two points.

distance_squared

The squared distance between two points.

dotDeprecated

Computes the dot product of two vectors.

idDeprecated

Gets the ubiquitous multiplicative identity element.

inf

Returns the infimum of a and b.

inf_sup

Returns simultaneously the infimum and supremum of a and b.

inverseDeprecated

Computes the multiplicative inverse of an (always invertible) algebraic entity.

is_convertible

Indicates if try_convert will succeed without actually performing the conversion.

magnitudeDeprecated

A synonym for norm, aka length.

magnitude_squaredDeprecated

A synonym for norm_squared, aka length squared.

max

Same as cmp::max.

min

Same as cmp::min.

normDeprecated

Computes the L2 (Euclidean) norm of a vector.

norm_squaredDeprecated

Computes the squared L2 (Euclidean) norm of the vector v.

normalizeDeprecated

Computes the normalized version of the vector v.

one

Gets the multiplicative identity element.

originDeprecated

Gets the origin of the given point.

partial_clamp

Clamp value between min and max. Returns None if value is not comparable to min or max.

partial_cmp

Compare a and b using a partial ordering relation.

partial_ge

Returns true iff a and b are comparable and a >= b.

partial_gt

Returns true iff a and b are comparable and a > b.

partial_le

Returns true iff a and b are comparable and a <= b.

partial_lt

Returns true iff a and b are comparable and a < b.

partial_max

Return the maximum of a and b if they are comparable.

partial_min

Return the minimum of a and b if they are comparable.

partial_sort2

Sorts two values in increasing order using a partial ordering.

sup

Returns the supremum of a and b.

try_convert

Attempts to convert an object to a more specific one.

try_convert_ref

Attempts to convert an object to a more specific one.

try_inverseDeprecated

Tries to gets an inverted copy of a square matrix.

try_normalizeDeprecated

Computes the normalized version of the vector v or returns None if its norm is smaller than min_norm.

wrap

Wraps val into the range [min, max] using modular arithmetics.

zero

Gets the additive identity element.