Debian Codegraph @

debian/missing-sources/glam-0.20.5/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.52]
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` and
37 `wasm32` architectures. As a result, these types are all 16 byte aligned and
38 depending on the size of the type or the type's members, they may contain
39 internal padding. This results in some wasted space in the cases of `Vec3A`,
40 `Mat3A`, `Affine2` and `Affine3A`. However, the use of SIMD generally results
41 in better 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 ### Enabling SIMD
49
50 SIMD is supported on `x86`, `x86_64` and `wasm32` targets.
51
52 * `SSE2` is enabled by default on `x86_64` targets.
53 * To enable `SSE2` on `x86` targets add `-C target-feature=+sse2` to
54 `RUSTCFLAGS`.
55 * To enable `simd128` on `wasm32` targets add `-C target-feature=+simd128` to
56 `RUSTFLAGS`.
57
58 Note that SIMD on `wasm32` passes tests but has not been benchmarked,
59 performance may or may not be better than scalar math.
60
61 ### `no_std` support
62
63 `no_std` support can be enabled by compiling with `--no-default-features` to
64 disable `std` support and `--features libm` for math functions that are only
65 defined in `std`. For example:
66
67 ```toml
68 [dependencies]
69 glam = { version = "0.20.4", default-features = false, features = ["libm"] }
70 ```
71
72 To support both `std` and `no_std` builds in project, you can use the following
73 in your `Cargo.toml`:
74
75 ```toml
76 [features]
77 default = ["std"]
78
79 std = ["glam/std"]
80 libm = ["glam/libm"]
81
82 [dependencies]
83 glam = { version = "0.20.4", default-features = false }
84 ```
85
86 ### Optional features
87
88 * [`approx`] - traits and macros for approximate float comparisons
89 * [`bytemuck`] - for casting into slices of bytes
90 * [`libm`] - required to compile with `no_std`
91 * [`mint`] - for interoperating with other 3D math libraries
92 * [`num-traits`] - required to compile `no_std`, will be included when enabling
93 the `libm` feature
94 * [`rand`] - implementations of `Distribution` trait for all `glam` types.
95 * [`serde`] - implementations of `Serialize` and `Deserialize` for all `glam`
96 types. Note that serialization should work between builds of `glam` with and
97 without SIMD enabled
98 * [`rkyv`] - implementations of `Archive`, `Serialize` and `Deserialize` for all
99 `glam` types. Note that serialization is not interoperable with and without the
100 `scalar-math` feature. It should work between all other builds of `glam`.
101 Endian conversion is currently not supported
102 * [`bytecheck`] - to perform archive validation when using the `rkyv` feature
103 * [`fast-math`] - By default, glam attempts to provide bit-for-bit identical
104 results on all platforms. Using this feature will enable platform specific
105 optimizations that may not be identical to other platforms. **Intermediate
106 libraries should not use this feature and defer the decision to the final
107 binary build**.
108
109 [`approx`]: https://docs.rs/approx
110 [`bytemuck`]: https://docs.rs/bytemuck
111 [`libm`]: https://github.com/rust-lang/libm
112 [`mint`]: https://github.com/kvark/mint
113 [`num-traits`]: https://github.com/rust-num/num-traits
114 [`rand`]: https://github.com/rust-random/rand
115 [`serde`]: https://serde.rs
116 [`rkyv`]: https://github.com/rkyv/rkyv
117 [`bytecheck`]: https://github.com/rkyv/bytecheck
118
119 ### Feature gates
120
121 * `scalar-math` - compiles with SIMD support disabled
122 * `debug-glam-assert` - adds assertions in debug builds which check the validity
123 of parameters passed to `glam` to help catch runtime errors
124 * `glam-assert` - adds validation assertions to all builds
125 * `cuda` - forces `glam` types to match expected [cuda alignment]
126
127 [cuda alignment]: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#built-in-vector-types
128
129 ### Minimum Supported Rust Version (MSRV)
130
131 The minimum supported version of Rust for `glam` is `1.52.1`.
132
133 `wasm32` SIMD intrinsics require Rust `1.54.0`.
134
135 ## Conventions
136
137 ### Column vectors
138
139 `glam` interprets vectors as column matrices (also known as "column vectors")
140 meaning when transforming a vector with a matrix the matrix goes on the left,
141 e.g. `v' = Mv`. DirectX uses row vectors, OpenGL uses column vectors. There
142 are pros and cons to both.
143
144 ### Column-major order
145
146 Matrices are stored in column major format. Each column vector is stored in
147 contiguous memory.
148
149 ### Co-ordinate system
150
151 `glam` is co-ordinate system agnostic and intends to support both right-handed
152 and left-handed conventions.
153
154 ## Design Philosophy
155
156 The design of this library is guided by a desire for simplicity and good
157 performance.
158
159 * No generics and minimal traits in the public API for simplicity of usage
160 * All dependencies are optional (e.g. `mint`, `rand` and `serde`)
161 * Follows the [Rust API Guidelines] where possible
162 * Aiming for 100% test [coverage]
163 * Common functionality is benchmarked using [Criterion.rs]
164
165 [Rust API Guidelines]: https://rust-lang-nursery.github.io/api-guidelines/
166 [coverage]: coveralls.io
167 [Criterion.rs]: https://bheisler.github.io/criterion.rs/book/index.html
168
169 ## Architecture
170
171 See [ARCHITECTURE.md] for details on `glam`'s internals.
172
173 [ARCHITECTURE.md]: ARCHITECTURE.md
174
175 ## Inspirations
176
177 There were many inspirations for the interface and internals of glam from the
178 Rust and C++ worlds. In particular:
179
180 * [How to write a maths library in 2016] inspired the initial `Vec3A`
181 implementation
182 * [Realtime Math] - header only C++11 with SSE and NEON SIMD intrinsic support
183 * [DirectXMath] - header only SIMD C++ linear algebra library for use in games
184 and graphics apps
185 * `glam` is a play on the name of the popular C++ library [GLM]
186
187 [How to write a maths library in 2016]: http://www.codersnotes.com/notes/maths-lib-2016/
188 [Realtime Math]: https://github.com/nfrechette/rtm
189 [DirectXMath]: https://docs.microsoft.com/en-us/windows/desktop/dxmath/directxmath-portal
190 [GLM]: https://glm.g-truc.net
191
192 ## License
193
194 Licensed under either of
195
196 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE)
197 or http://www.apache.org/licenses/LICENSE-2.0)
198 * MIT license ([LICENSE-MIT](LICENSE-MIT)
199 or http://opensource.org/licenses/MIT)
200
201 at your option.
202
203 ## Contribution
204
205 Contributions in any form (issues, pull requests, etc.) to this project must
206 adhere to Rust's [Code of Conduct].
207
208 Unless you explicitly state otherwise, any contribution intentionally submitted
209 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
210 dual licensed as above, without any additional terms or conditions.
211
212 Thank you to all of the `glam` [contributors]!
213
214 [Code of Conduct]: https://www.rust-lang.org/en-US/conduct.html
215 [contributors]: https://github.com/bitshifter/glam-rs/graphs/contributors
216
217 ## Support
218
219 If you are interested in contributing or have a request or suggestion
220 [start a discussion] on GitHub. See [CONTRIBUTING.md] for more information for
221 contributors.
222
223 The [Game Development in Rust Discord] and [Bevy Engine Discord] servers are
224 not official support channels but can be good places to ask for help with
225 `glam`.
226
227 [start a discussion]: https://github.com/bitshifter/glam-rs/discussions
228 [CONTRIBUTING.md]: CONTRIBUTING.md
229 [Game Development in Rust Discord]: https://discord.gg/yNtPTb2
230 [Bevy Engine Discord]: https://discord.gg/gMUk5Ph
231
232 ## Attribution
233
234 `glam` contains code ported from the following C++ libraries:
235
236 * [DirectXMath] - MIT License - Copyright (c) 2011-2020 Microsoft Corp
237 * [Realtime Math] - MIT License - Copyright (c) 2018 Nicholas Frechette
238 * [GLM] - MIT License - Copyright (c) 2005 - G-Truc Creation
239
240 See [ATTRIBUTION.md] for details.
241
242 [ATTRIBUTION.md]: ATTRIBUTION.md
243
244 [Build Status]: https://github.com/bitshifter/glam-rs/actions/workflows/ci.yml/badge.svg
245 [github-ci]: https://github.com/bitshifter/glam-rs/actions/workflows/ci.yml
246 [Coverage Status]: https://coveralls.io/repos/github/bitshifter/glam-rs/badge.svg?branch=main
247 [coveralls.io]: https://coveralls.io/github/bitshifter/glam-rs?branch=main
248 [Latest Version]: https://img.shields.io/crates/v/glam.svg
249 [crates.io]: https://crates.io/crates/glam/
250 [docs]: https://docs.rs/glam/badge.svg
251 [docs.rs]: https://docs.rs/glam/
252 [Minimum Supported Rust Version]: https://img.shields.io/badge/Rust-1.52.1-blue?color=fc8d62&logo=rust
253 [Rust 1.52]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1521-2021-05-10