495: Mat3 constructors enhancement r=kvark a=AndreaCatania
The reason of this PR is because I need to transform thing in a 2d plane, and these functions are really handy.
- Added to the Mat3 the possibility to be constructed from a translation vector, similarly to the Mat4.
- Added unit tests.
Co-authored-by: Andrea Catania <info@andreacatania.com>
491: Fix Matrix2::look_at, add look_at_stable r=kvark a=blargg
## Changes
1. Fixes `Matrix2::look_at`
2. Adds tests for `look_at`
3. Adds a new function, `look_at_stable`
## Notes
I added a new function for 2d look at rotation. `look_at` is a bit weird in practice for 2d. For example, if you are making a basis matrix to orient a 2d character to look at a point, `look_at` will flip the character as they rotate past `up` or `-up` vectors. This is the best match for what look_at is supposed to do, I think.
`look_at_stable` will not flip based on orientation, you just pass in which way to flip. This is a bit easier to use to rotate 2d characters.
`look_at_stable` could have a better name. I think we can also consider removing the flip param, and just let the user flip the matrix with a transform later.
Co-authored-by: blargg <tomjankauski@gmail.com>
492: Clean up specialization and simd r=kvark a=NNemec
The current SIMD implementation is based on the deprecated "simd" package and requires the unstable feature "specialization". So far, this was handled by significant code duplication and added complexity, making everything harder to understand even when "simd" was not in use at all.
In order to migrate from "simd" to "packed_simd" it appears valuable to first clean up the existing "simd" code, see what is still valuable and then see how to migrate.
This change reduces duplication, introduces a clear distinction of the "simd" feature and the "specialization" feature and moves most "simd" related code into separate source files.
The code is pure refactoring, keeping all functionality unchanged.
Testing the "simd" feature requires the 1.32 toolchain and commenting out the glium dev dependency. With that all tests run successfully.
Co-authored-by: Norbert Nemec <norbert@nemec-online.de>
486: Implement zip for VectorN and PointN r=kvark a=mickvangelderen
Implements #485.
It is possible but messy to put `map` and `zip` in the Array trait. Rust doesn't support higher kinded types which would help because we want to abstract over any container, holding a fixed number of some item type. The implementation would basically need to reproduce the work in the generic-array crate which is silly.
Co-authored-by: Mick van Gelderen <mickvangelderen@gmail.com>
483: Make `rand` dependency optional (but enabled by default) r=kvark a=LukasKalbertodt
Closes#481
This PR leaves the feature enabled by default so that this can be released as a minor version soon. (I would suggest to disable it by default in future versions, but that's another discussion.)
The changes are pretty straight forward with one catch: I changed some `use` statements to nested imports (otherwise, there would be even more `#[cfg(feature = "rand")]` lines). Nested imports were stabilized in 1.25 (see [the edition guide on this feature](https://doc.rust-lang.org/edition-guide/rust-2018/module-system/nested-imports-with-use.html)). I'm not sure how cgmaths policy on minimum compiler version is. Maybe cgmath already requires a >= 1.25 compiler for other reasons. If my change is a problem, just tell me and I will change the imports back.
Co-authored-by: Lukas Kalbertodt <lukas.kalbertodt@gmail.com>
Most users probably don't use the rand impls, so the `rand` crate pulls
a large number of dependencies into the dependency tree which is just
wasted compilation time.
480: Add documentation for `<Quaternion as Rotation<Point3<S>>>::rotate_vector` r=kvark a=tangmi
Clarifies that a quaternion should be normalized to be used as a rotation. Does not enforce or assert that the quaternion is normalized because valid rotations can be slightly off of the unit quaternion due to floating point error.
Fixes#479.
Co-authored-by: Michael Tang <tangmi@uw.edu>
476: Add short constructors for points, to match the ones for vectors r=kvark a=nstoddard
In my code I find that I need to create points almost as often as vectors, so having short constructors is helpful.
Co-authored-by: Nathan Stoddard <nstoddard@users.noreply.github.com>
478: Readme links update, let travis fail on nightly r=kvark a=kvark
This is unfortunate, but it appears that we need to move to the new SIMD API in order to unblock it.
Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
438: Angle: add the normalize_zero method r=kvark a=mathstuf
This method is like `normalize` except that it normalizes to have an
absolute value of no more than `turn_div_2`.
---
This is useful for making sure that an angle is no more than some offset from a target angle (e.g., implementing maximum turn rates in games).
Co-authored-by: Ben Boeckel <mathstuf@gmail.com>
472: [breaking] Move lerp() from InnerSpace to VectorSpace r=Rhuagh a=Vlad-Shcherbina
Because it does not require dot product.
Along the way, fix the comment.
Fixes#471.
Co-authored-by: Vlad Shcherbina <vlad.shcherbina@gmail.com>
475: Declare vector constructors to be const r=kvark a=nstoddard
This makes it easier to create vectors in constants.
Co-authored-by: Nathan Stoddard <nstoddard@users.noreply.github.com>