Skip to main content

Crate windows_numerics

Crate windows_numerics 

Source
Expand description

§windows-numerics

The windows-numerics crate provides Windows vector, matrix, plane, and quaternion types.

These are the same graphics math types used by composition, Direct2D, and Direct3D APIs, so values flow into those APIs without conversion.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-numerics]
version = "0.100"

Use the vector and matrix types as needed:

use windows_numerics::*;

let a = Vector2::new(3.0, 4.0);
assert_eq!(a.length(), 5.0);

let b = Vector3::new(1.0, 0.0, 0.0);
let c = Vector3::new(0.0, 1.0, 0.0);
assert_eq!(b.cross(&c), Vector3::new(0.0, 0.0, 1.0));

let transform = Matrix3x2::translation(10.0, 20.0);
assert_eq!(transform.m31, 10.0);
assert_eq!(transform.m32, 20.0);

Structs§

Matrix3x2
Matrix4x4
Vector2
Vector3
Vector4