Commit Graph

156 Commits

Author SHA1 Message Date
Christopher Durham f578181351 Fix glm::is_normalized epsilon
The existing comparison bound of $\epsilon^2$ is improperly scaled for
testing an epsilon of the squared vector magnitude. Let $\epsilon$ be
our specified epsilon and $\delta$ be the permissible delta of the
squared magnitude. Thus, for a nearly-normalized vector, we have

$$\begin{align}
\sqrt{1 + \delta} &=  1 + \epsilon        \\
          \delta  &= (1 + \epsilon)^2 - 1 \\
          \delta  &=  \epsilon^2 + 2\epsilon
\text{ .}\end{align}$$

Since we only care about small epsilon, we can assume
that $\epsilon^2$ is small and just use $\delta = 2\epsilon$. And in
fact, [this is the bound used by GLM][GLM#isNormalized] (MIT license)
... except they're using `length` and not `length2` for some reason.

[GLM#isNormalized]: b06b775c1c/glm/gtx/vector_query.inl (L102)

If we stick an epsilon of `1.0e-6` into the current implementation,
this gives us a computed delta of `1.0e-12`: smaller than the `f32`
machine epsilon, and thus no different than direct float comparison
without epsilon. This also gives an effetive epsilon of `5.0e-13`;
*much* less than the intended `1.0e-6` of intended permitted slack!
By doing a bit more algebra, we can find the effective epsilon is
$\sqrt{\texttt{epsilon}^2 + 1} - 1$. This patch makes the effective
epsilon $\sqrt{2\times\texttt{epsilon} + 1} - 1$ which still isn't
*perfect*, but it's effectively linear in the domain we care about,
only really making a practical difference above an epsilon of 10%.

TL;DR: the existing `is_normalized` considers a vector normalized if
the squared magnitude is within `epsilon*epsilon` of `1`. This is wrong
and it should be testing if it's within `2*epsilon`. This PR fixes it.

For absence of doubt, a comparison epsilon of $\texttt{epsilon}^2$ is
correct when comparing squared magnitude against zero, such as when
testing if a displacement vector is nearly zero.
2024-01-13 00:02:26 -05:00
Ababwa 0b89950fca Correct less than or equal symbol in doc in vector_relational.rs
Less than or equal <=
2024-01-11 23:24:13 -08:00
Benjamin Saunders 7866bcee5c Remove CUDA support relying on abandoned toolchain 2024-01-11 23:09:17 -08:00
Fabio Valentini bad63b6423
Fix and clarify license in crate metadata and add missing license files 2023-10-24 18:33:53 +02:00
Sébastien Crozet c6ff3eeb7e
Merge pull request #1265 from waywardmonkeys/fix-html-links
docs: Use intradoc links rather than HTML.
2023-09-30 18:24:28 +02:00
Sébastien Crozet 2043824058
Merge pull request #1281 from waywardmonkeys/clippy-single_component_path_imports
nalgebra-glm: Fix clippy single_component_path_imports.
2023-09-30 18:16:16 +02:00
Sébastien Crozet 1987ca29bb
Merge pull request #1282 from waywardmonkeys/clippy-needless-borrow
clippy: Fix needless_borrow warnings.
2023-09-30 18:15:42 +02:00
Bruce Mitchener 1b1d950f74 nalgebra-glm, clippy: Suppress too_many_arguments.
Matrix constructors need more args.
2023-08-19 01:00:01 +07:00
Bruce Mitchener 1d9a4bf6ec clippy: Fix needless_borrow warnings. 2023-08-19 00:36:24 +07:00
Bruce Mitchener 8609167053 nalgebra-glm: Fix clippy single_component_path_imports.
These imports are redundant and not needed.
2023-08-19 00:19:42 +07:00
Bruce Mitchener 136a565579 docs: Use intradoc links rather than HTML.
This fixes almost all HTML links to be intradoc links that Rust
can verify during `cargo doc`. This will help prevent future
broken links.
2023-08-06 22:34:40 +07:00
Chris Ohk fd97a82926 fix: Correct minor typos 2023-02-01 15:48:06 +09:00
Sébastien Crozet 8aa34a952f Release v0.32.0 2023-01-14 17:04:22 +01:00
Andreas Longva f007772f4b Update slice->view in nalgebra-glm 2022-11-14 15:18:28 +01:00
Sébastien Crozet b656faa233 Release v0.31.0 2022-04-30 10:59:26 +02:00
Sébastien Crozet c9bf6aa95f Fix warnings 2022-04-28 14:58:15 +02:00
Ben Kimock 698e130c3b Remove abomonation support
Abomonation has numerous soundness problems which have been
well-documented in its issue tracker for over 2 years. Some of them
could be fixed, but some are fundamental to its design. If a user wants
super-fast ser/de, they should use rkyv.
2022-02-05 17:15:08 -05:00
Sébastien Crozet e8b9c40123 Release v0.30.0 2022-01-02 15:30:15 +01:00
Arthur Kaukal Valladares c72b30d628 Fix typo in `nalgebra_glm::radians` doc comment 2021-11-26 18:51:01 -08:00
Sébastien Crozet 5d9562f7d8 nalgebra-glm: add a cuda feature 2021-11-23 13:57:30 +01:00
Sébastien Crozet 8c2bdf51f2 Run cargo fmt 2021-11-21 21:21:22 +01:00
Sébastien Crozet a35918b613 nalgebra-glm: fix no-std build 2021-11-21 21:11:55 +01:00
Stock84-dev 3c882abd83 Forward conversion features 2021-09-30 19:30:53 +02:00
Sébastien Crozet 857bd75c33 Add doc-test for nalgebra_glm::mat3 2021-09-25 12:09:32 +02:00
InnocentusLime ebfab8dcfd Attempt to fix #984 2021-09-10 18:27:19 +03:00
Sébastien Crozet d1d7422761 Bump the version of nalgebra-glm, nalgebra-lapack, and nalgebra-sparse. 2021-08-08 18:07:34 +02:00
Sébastien Crozet db63f6c031 Release v0.29.0 2021-08-08 17:54:35 +02:00
Sébastien Crozet 6165ac8dbf Fix nalgebra-glm tests. 2021-08-08 13:05:13 +02:00
Sébastien Crozet 85074398d0 Fix nalgebra-glm 2021-08-08 12:59:40 +02:00
Sébastien Crozet dd6c40016e Remove the Copy requirement from SimdRealField. 2021-08-04 17:34:25 +02:00
Sébastien Crozet dcd92827a9
Merge pull request #956 from remilauzier/dev
Fix some warnings
2021-08-01 10:28:45 +02:00
Zacchary Dempsey-Plante 6eb642625b
Fix a typo in the doc comment for `Mat2x3`
Currently, the doc comment for `Mat2x3` incorrectly describes it as a 2x2 matrix. Obviously this is a very minor issue, but I figured it was worth fixing.
2021-07-30 16:18:31 +00:00
Rémi Lauzier c35f792b4f
Fix some warnings 2021-07-27 19:24:55 -04:00
Crozet Sébastien ca1297acfb Release v0.28.0 2021-07-11 17:42:45 +02:00
Violeta Hernández 6e96c28ad9 Trivial doc comment improvements 2021-07-06 21:05:25 -05:00
Crozet Sébastien dfc8ad3d6a Release v0.27.0 2021-06-02 15:15:17 +02:00
Crozet Sébastien c5c6c139ab Release v0.26.0 2021-04-12 16:15:08 +02:00
Crozet Sébastien 95b021dbfb Don't enable serde by default.
Don't enable `serde/std` by default.
Add a `serde-serialize-no-std` feature to enable serde without its default features.
2021-04-12 12:14:16 +02:00
Crozet Sébastien 24d546d3b6 Rename generic parameter N -> T 2021-04-11 13:57:54 +02:00
Crozet Sébastien 5b9b94c610 Release v0.25.0 2021-03-01 14:25:29 +01:00
Crozet Sébastien 6cfd2bca14 Use proptest for all nalgebra tests. 2021-02-28 17:52:14 +01:00
Crozet Sébastien 7d5cc4912d Update cargo badge and categories. 2021-01-29 13:33:37 +01:00
Crozet Sébastien b695aaa807 Release v0.24.0 2020-12-30 15:11:23 +01:00
Crozet Sébastien e852df6124 Add sections for most Matrix methods. 2020-11-15 16:57:49 +01:00
Crozet Sébastien a2b128c4e4 Release nalgebra-glm v0.9.0 2020-10-26 09:41:02 +01:00
Crozet Sébastien 3b723d7b9c Bump dependencies for nalgebra-glm and nalgebra-lapack. 2020-10-25 15:13:56 +01:00
Philippe Renon fb15658cc9 fix typo: apsect should be aspect 2020-10-11 11:42:22 +02:00
Sébastien Crozet 1e65fb948d Release nalgebra-glm v0.8.0 2020-08-25 21:16:06 +02:00
Sébastien Crozet a6962dfadc Bump the simba dependency version. 2020-08-25 20:46:35 +02:00
sebcrozet 0be9a07f8b Use the #[rustfmt::skip] attribute instead of rustfmt_skip. 2020-06-07 09:30:21 +02:00