math_utils/
lib.rs

1//! Math types and traits
2//!
3//! ## Vectors & points
4//!
5//! - [`Vector2`]
6//! - [`Vector3`]
7//! - [`Vector4`]
8//! - [`Point2`]
9//! - [`Point3`]
10//! - [`Point4`]
11//! - [`Unit2`]
12//! - [`Unit3`]
13//! - [`Unit4`]
14//! - [`NonZero2`]
15//! - [`NonZero3`]
16//! - [`NonZero4`]
17//!
18//! ## Matrices & rotations
19//!
20//! Matrices are *column-major* for SIMD efficiency.
21//!
22//! - [`Matrix2`]
23//! - [`Matrix3`]
24//! - [`Matrix4`]
25//! - [`Rotation2`]
26//! - [`Rotation3`]
27//! - [`Quaternion`]
28//! - [`Versor`]
29//!
30//! ## Affine transformations
31//!
32//! - [`AffineMap`]
33//! - [`Affinity`]
34//! - [`Projectivity`]
35
36#![feature(decl_macro)]
37#![feature(stmt_expr_attributes)]
38
39pub use vek::approx;
40pub use vek::num_traits;  // TODO: re-export as num ?
41pub use vek;
42
43pub mod data;
44pub mod geometry;
45pub mod algebra;
46
47mod fixed;
48mod traits;
49mod types;
50
51pub use self::fixed::*;
52pub use self::traits::*;
53pub use self::types::*;
54
55/// 0
56pub const COMPONENT_INDEX_X : usize = 0;
57/// 1
58pub const COMPONENT_INDEX_Y : usize = 1;
59/// 2
60pub const COMPONENT_INDEX_Z : usize = 2;
61/// 3
62pub const COMPONENT_INDEX_W : usize = 3;
63
64
65/// Convenience macro
66#[doc(hidden)]
67#[macro_export]
68macro_rules! show {
69  ($e:expr) => { println!("{}: {:?}", stringify!($e), $e); }
70}
71
72/// Print the sizes of some types
73pub fn report_sizes() {
74  use std::mem::size_of;
75  println!("report sizes...");
76  show!(size_of::<Vector2 <f32>>());
77  show!(size_of::<Vector3 <f32>>());
78  show!(size_of::<Vector4 <f32>>());
79  show!(size_of::<Matrix2 <f32>>());
80  show!(size_of::<Matrix3 <f32>>());
81  show!(size_of::<Rotation2 <f32>>());
82  show!(size_of::<Rotation3 <f32>>());
83  show!(size_of::<AffineMap <f32, Point3 <f32>, Point3 <f32>, Matrix3 <f32>>>());
84  show!(size_of::<AffineMap <f32, Point4 <f32>, Point4 <f32>, Matrix4 <f32>>>());
85  println!("...report sizes");
86}