Commit graph

1552 commits

Author SHA1 Message Date
Luyu Cheng
a691de8714
Fix a type parameter in benchmarks (#517) 2020-09-01 17:28:51 -04:00
josh65536
84da664455
Now there is only one one (#513)
* Now there is only one one

* Rotation no longer has a parameter

* Moved some type parameters to associated types

* Relaxed some bounds and simplified a bound

* Removed unnecessary bound in

* Deduplicated multiplication code
2020-08-12 15:05:38 -04:00
josh65536
816c043223
Fixed opposite quaternion slerp bug (#515)
* Fixed opposite quaternion slerp bug

* Removed an unnecessary

* nlerp and slerp always take the shortest path now
2020-08-11 23:04:27 -04:00
Marco Giordano
c96cd57efc
Allow inverted near far for inverted depth fp32 (#509)
* removed assertion for inverted near far

* added extra assertion

* adding checks for ratio too small or far and near plane too close to each other

* using comparing macro

* PR feedback
2020-06-24 10:45:20 -04:00
Nathan Stoddard
2c7ee50ef4 Fix compilation of benchmarks
This switches to `SmallRng` since that doesn't require adding another dependency.
2020-06-04 15:15:38 -04:00
Nathan Stoddard
8d0e3f4eae Remove Float bound from MetricSpace and InnerSpace; move Float bound to individual methods
This makes it possible to call methods like `dot` on integers.
2020-06-03 16:07:04 -04:00
Egor Larionov
9dcd9fc3dd Remove unused commented out code 2020-05-23 00:50:32 -04:00
Egor Larionov
753773cfcd Further relax InnerSpace and is_finite BaseFloat bounds 2020-05-23 00:50:32 -04:00
Egor Larionov
b9e82914db Relax Float bound {Metric,Inner}Space and Matrix traits
This makes the trait more flexible.
This contributes to #496.
2020-05-23 00:50:32 -04:00
bors[bot]
50a345b7c4
Merge #495
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>
2019-11-05 15:03:30 +00:00
Andrea Catania
ff1cda766d Code formatted with 2019-11-05 07:16:38 +01:00
Andrea Catania
04b21718f3 Added to the Mat3 the possibility to be constructed from a translation vector. Added tests. 2019-11-05 07:15:33 +01:00
bors[bot]
f69e781b8f
Merge #491
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>
2019-09-03 22:13:25 +00:00
blargg
dd9f08ccee Fix Matrix2::look_at, add look_at_stable
Fix bug in look_at

Use the up vector to determine turn direction

Add look_at_stable

Matrix2::look_at calls look_at_stable
2019-09-03 17:02:11 -05:00
bors[bot]
981170fc19
Merge #492
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>
2019-09-03 17:35:33 +00:00
Norbert Nemec
c7e7d4895e add README and CHANGELOG entries 2019-09-03 19:33:44 +02:00
Norbert Nemec
5c6c378128 add "simd" test with nightly-2019-01-01 toolchain and get it working 2019-09-01 22:56:26 +02:00
Norbert Nemec
153754eb38 split off code into quaternion_simd.rs 2019-09-01 21:04:05 +02:00
Norbert Nemec
f21232a123 drop redundant copies from quaternion.rs 2019-09-01 21:04:05 +02:00
Norbert Nemec
7290d42c04 split off code into vector_simd.rs 2019-09-01 21:04:05 +02:00
Norbert Nemec
dfb8766e38 drop redundant impl_vector_default 2019-09-01 21:04:05 +02:00
Norbert Nemec
c4acb79d04 merge default_fn!() from impl_vector_default back into impl_vector 2019-09-01 21:04:05 +02:00
Norbert Nemec
64fde2002b replace default -> default_fn!() 2019-09-01 21:04:04 +02:00
Norbert Nemec
caa8ee13fd merge changes from impl_vector to impl_vector_default 2019-09-01 21:04:04 +02:00
Norbert Nemec
40d0afd036 drop redundant impl_scalar_ops_default 2019-09-01 21:04:04 +02:00
Norbert Nemec
1c7c889921 drop redundancy of impl_operator_default and impl_assignment_operator_default 2019-09-01 21:04:04 +02:00
Norbert Nemec
fde164293b default_fn! macro 2019-09-01 21:04:04 +02:00
Norbert Nemec
bfaec62c87 .gitignore .vs/ 2019-09-01 20:59:00 +02:00
Norbert Nemec
baa50d8b86 fix warning 2019-09-01 20:59:00 +02:00
Norbert Nemec
935f389983 replace deprecated try! macro by ? operator 2019-09-01 15:16:03 +02:00
Dzmitry Malyshau
ec5261d15b
Merge pull request #488 from spearman/bump-rand
bump rand -> 0.7, fix unused macro warnings in tests
2019-08-12 16:17:53 -04:00
Shane Pearman
2387544e08 bump rand -> 0.7, fix unused macro warnings in tests 2019-08-11 16:59:47 -07:00
bors[bot]
fcf59c8082 Merge #486
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>
2019-06-12 15:10:35 +00:00
Mick van Gelderen
a63843c30a Implement zip for VectorN and PointN
Impelements #485
2019-06-10 10:51:30 +02:00
bors[bot]
627d1c589f Merge #483
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>
2019-05-03 14:47:52 +00:00
Lukas Kalbertodt
31cb9eb574
Remove rand from default features 2019-05-03 16:31:14 +02:00
Lukas Kalbertodt
9e650fd8ad
Adjust Travis-CI config to build with and without rand 2019-05-02 18:09:16 +02:00
Dzmitry Malyshau
9e67e6cdc4
Merge pull request #482 from Plotnus/patch-1
fixed dropped 's' in trait.
2019-05-02 10:42:27 -04:00
Lukas Kalbertodt
4bd8ebb38d
Make rand dependency optional (but enabled by default)
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.
2019-05-02 11:24:50 +02:00
Jonathan Plotner
107f90c2e5
fixed dropped 's' in trait.
Grammatical change from singular to plural.
2019-04-25 12:47:35 -07:00
bors[bot]
93786bfc9a Merge #480
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>
2019-03-23 14:40:10 +00:00
Michael Tang
c1f808d928 Add documentation for <Quaternion as Rotation<Point3<S>>>::rotate_vector. Fixes #479. 2019-03-22 22:01:47 -07:00
bors[bot]
9402a01a5b Merge #476
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>
2019-02-25 16:34:53 +00:00
bors[bot]
0e75148fc5 Merge #478
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>
2019-02-25 16:25:49 +00:00
Dzmitry Malyshau
605fb26819 Readme links update, let travis fail on nightly 2019-02-25 11:13:45 -05:00
Dzmitry Malyshau
7e390571bf
Update CHANGELOG.md 2019-01-17 13:14:36 -05:00
Dzmitry Malyshau
2f2988c4cf
Update CHANGELOG.md 2019-01-17 13:10:41 -05:00
bors[bot]
8bc3af42ef Merge #438
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>
2019-01-16 22:30:23 +00:00
Ben Boeckel
1b57dc93a5 tests: add tests for Angle::normalize 2019-01-16 16:02:37 -05:00
Ben Boeckel
2d2c501074 Angle: add the normalize_signed method
This method is like `normalize` except that it normalizes to have an
absolute value of no more than `turn_div_2`.
2019-01-16 16:01:46 -05:00