Debian Codegraph @

debian/missing-sources/glam-0.15.2/README.md

raw symbols SCIP
1 # glam
2
3 [![Build Status]][github-ci] [![Coverage Status]][coveralls.io]
4 [![Latest Version]][crates.io] [![docs]][docs.rs]
5 [![Minimum Supported Rust Version]][Rust 1.45]
6
7 A simple and fast 3D math library for games and graphics.
8
9 ## Development status
10
11 `glam` is in beta stage. Base functionality has been implemented and the look
12 and feel of the API has solidified.
13
14 ## Features
15
16 * `f32` types
17 * vectors: `Vec2`, `Vec3`, `Vec3A` and `Vec4`
18 * square matrices: `Mat2`, `Mat3`, `Mat3A` and `Mat4`
19 * a quaternion type: `Quat`
20 * affine transformation types: `Affine2` and `Affine3A`
21 * `f64` types
22 * vectors: `DVec2`, `DVec3` and `DVec4`
23 * square matrices: `DMat2`, `DMat3` and `DMat4`
24 * a quaternion type: `DQuat`
25 * affine transformation types: `DAffine2` and `DAffine3`
26 * `i32` types
27 * vectors: `IVec2`, `IVec3` and `IVec4`
28 * `u32` types
29 * vectors: `UVec2`, `UVec3` and `UVec4`
30 * `bool` types
31 * vectors: `BVec2`, `BVec3` and `BVec4`
32
33 ### SIMD
34
35 The `Vec3A`, `Vec4`, `Quat`, `Mat2`, `Mat3A`, `Mat4`, `Affine2` and `Affine3A`
36 types use 128-bit wide SIMD vector types for storage on x86/x86_64
37 architectures. As a result, these types are all 16 byte aligned and depending
38 on the size of the type or the type's members, they may contain internal
39 padding. This results in some wasted space in the cases of `Vec3A`, `Mat3A`,
40 `Affine2` and `Affine3A`. However the use of SIMD generally results in better
41 performance than scalar math.
42
43 `glam` outperforms similar Rust libraries for common operations as tested by the
44 [`mathbench`][mathbench] project.
45
46 [mathbench]: https://github.com/bitshifter/mathbench-rs
47
48 ### `no_std` support
49
50 `no_std` support can be enabled by compiling with `--no-default-features` to
51 disable `std` support and `--features libm` for math functions that are only
52 defined in `std`. For example:
53
54 ```toml
55 [dependencies]
56 glam = { version = "0.15.2", default-features = false, features = ["libm"] }
57 ```
58
59 To support both `std` and `no_std` builds in project, you can use the following
60 in your `Cargo.toml`:
61
62 ```toml
63 [features]
64 default = ["std"]
65
66 std = ["glam/std"]
67 libm = ["glam/libm"]
68
69 [dependencies]
70 glam = { version = "0.15.2", default-features = false }
71 ```
72
73 ### Optional features
74
75 * [`bytemuck`] - for casting into slices of bytes
76 * [`libm`] - required to compile with `no_std`
77 * [`mint`] - for interoperating with other 3D math libraries
78 * [`num-traits`] - required to compile `no_std`, will be included when enabling
79 the `libm` feature
80 * [`rand`] - implementations of `Distribution` trait for all `glam` types. This
81 is primarily used for unit testing
82 * [`serde`] - implementations of `Serialize` and `Deserialize` for all `glam`
83 types. Note that serialization should work between builds of `glam` with and
84 without SIMD enabled
85
86 [`bytemuck`]: https://docs.rs/bytemuck
87 [`libm`]: https://github.com/rust-lang/libm
88 [`mint`]: https://github.com/kvark/mint
89 [`num-traits`]: https://github.com/rust-num/num-traits
90 [`rand`]: https://github.com/rust-random/rand
91 [`serde`]: https://serde.rs
92
93 ### Feature gates
94
95 * `scalar-math` - compiles with SIMD support disabled
96 * `debug-glam-assert` - adds assertions in debug builds which check the validity
97 of parameters passed to `glam` to help catch runtime errors
98 * `glam-assert` - adds validation assertions to all builds
99
100 ### Minimum Supported Rust Version (MSRV)
101
102 The minimum supported version of Rust for `glam` is `1.45.0`.
103
104 ## Conventions
105
106 ### Column vectors
107
108 `glam` interprets vectors as column matrices (also known as "column vectors")
109 meaning when transforming a vector with a matrix the matrix goes on the left,
110 e.g. `v' = Mv`. DirectX uses row vectors, OpenGL uses column vectors. There
111 are pros and cons to both.
112
113 ### Column-major order
114
115 Matrices are stored in column major format. Each column vector is stored in
116 contiguous memory.
117
118 ### Co-ordinate system
119
120 `glam` is co-ordinate system agnostic and intends to support both right handed
121 and left handed conventions.
122
123 ## Design Philosophy
124
125 The design of this library is guided by a desire for simplicity and good
126 performance.
127
128 * No generics and minimal traits in the public API for simplicity of usage
129 * All dependencies are optional (e.g. `mint`, `rand` and `serde`)
130 * Follows the [Rust API Guidelines] where possible
131 * Aiming for 100% test [coverage]
132 * Common functionality is benchmarked using [Criterion.rs]
133
134 [Rust API Guidelines]: https://rust-lang-nursery.github.io/api-guidelines/
135 [coverage]: coveralls.io
136 [Criterion.rs]: https://bheisler.github.io/criterion.rs/book/index.html
137
138 ## Future work
139
140 * Experiment with a using a 4x3 matrix as a 3D transform type that can be more
141 efficient than `Mat4` for certain operations like inverse and multiplies
142 * `wasm` support
143
144 ## Inspirations
145
146 There were many inspirations for the interface and internals of glam from the
147 Rust and C++ worlds. In particular:
148
149 * [How to write a maths library in 2016] inspired the initial `Vec3A`
150 implementation
151 * [Realtime Math] - header only C++11 with SSE and NEON SIMD intrinsic support
152 * [DirectXMath] - header only SIMD C++ linear algebra library for use in games
153 and graphics apps
154 * `glam` is a play on the name of the popular C++ library [GLM]
155
156 [How to write a maths library in 2016]: http://www.codersnotes.com/notes/maths-lib-2016/
157 [Realtime Math]: https://github.com/nfrechette/rtm
158 [DirectXMath]: https://docs.microsoft.com/en-us/windows/desktop/dxmath/directxmath-portal
159 [GLM]: https://glm.g-truc.net
160
161 ## License
162
163 Licensed under either of
164
165 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE)
166 or http://www.apache.org/licenses/LICENSE-2.0)
167 * MIT license ([LICENSE-MIT](LICENSE-MIT)
168 or http://opensource.org/licenses/MIT)
169
170 at your option.
171
172 ## Contribution
173
174 Contributions in any form (issues, pull requests, etc.) to this project must
175 adhere to Rust's [Code of Conduct].
176
177 Unless you explicitly state otherwise, any contribution intentionally submitted
178 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
179 dual licensed as above, without any additional terms or conditions.
180
181 Thank you to all of the `glam` [contributors]!
182
183 [Code of Conduct]: https://www.rust-lang.org/en-US/conduct.html
184 [contributors]: https://github.com/bitshifter/glam-rs/graphs/contributors
185
186 ## Support
187
188 If you are interested in contributing or have a request or suggestion
189 [start a discussion] on github. See [CONTRIBUTING.md] for more information for
190 contributors.
191
192 The [Game Development in Rust Discord] and [Bevy Engine Discord] servers can are
193 also good places to ask for help with `glam`.
194
195 [start a discussion]: https://github.com/bitshifter/glam-rs/discussions
196 [CONTRIBUTING.md]: CONTRIBUTING.md
197 [Game Development in Rust Discord]: https://discord.gg/yNtPTb2
198 [Bevy Engine Discord]: https://discord.gg/gMUk5Ph
199
200 ## Attribution
201
202 `glam` contains code ported from the following C++ libraries:
203
204 * [DirectXMath] - MIT License - Copyright (c) 2011-2020 Microsoft Corp
205 * [Realtime Math] - MIT License - Copyright (c) 2018 Nicholas Frechette
206 * [GLM] - MIT License - Copyright (c) 2005 - G-Truc Creation
207
208 See [ATTRIBUTION.md] for details.
209
210 [ATTRIBUTION.md]: ATTRIBUTION.md
211
212 [Build Status]: https://github.com/bitshifter/glam-rs/actions/workflows/ci.yml/badge.svg
213 [github-ci]: https://github.com/bitshifter/glam-rs/actions/workflows/ci.yml
214 [Coverage Status]: https://coveralls.io/repos/github/bitshifter/glam-rs/badge.svg?branch=master
215 [coveralls.io]: https://coveralls.io/github/bitshifter/glam-rs?branch=master
216 [Latest Version]: https://img.shields.io/crates/v/glam.svg
217 [crates.io]: https://crates.io/crates/glam/
218 [docs]: https://docs.rs/glam/badge.svg
219 [docs.rs]: https://docs.rs/glam/
220 [Minimum Supported Rust Version]: https://img.shields.io/badge/Rust-1.45.0-blue?color=fc8d62&logo=rust
221 [Rust 1.45]: https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html