Debian Codegraph @

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