Commit graph

1096 commits

Author SHA1 Message Date
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
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
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
935f389983 replace deprecated try! macro by ? operator 2019-09-01 15:16:03 +02: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
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
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
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
Nathan Stoddard
2cf020351e Add short constructors for points, to match the ones for vectors 2019-01-14 15:53:28 -08:00
bors[bot]
a570349a0d Merge #472
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>
2019-01-14 17:10:16 +00:00
Nathan Stoddard
c438536dac Declare the rest of the constructors to be const
This requires removing trait bounds from the constructors, and for Euler, removing the trait bound from the struct.
2019-01-13 22:42:16 -08:00
Nathan Stoddard
19f75b88e6 Declare point constructors to be const
Also add const to a vector constructor that I missed before.

Constructors for other types can't yet be const, because the compiler gives an error: "trait bounds other than `Sized` on const fn parameters are unstable".
2019-01-12 19:59:44 -08:00
Nathan Stoddard
9a20f1031c Declare vector constructors to be const
This makes it easier to create vectors in constants.
2019-01-12 14:53:20 -08:00
Bastien Orivel
036604ed49 Update some dependencies and bump version 2018-12-28 21:01:18 +01:00
Vlad Shcherbina
5512b6a0f7 [breaking] Move lerp() from InnerSpace to VectorSpace
Because it does not require dot product.
Along the way, fix the comment.

Fixes #471.
2018-11-22 17:43:21 +03:00
Lukas Kalbertodt
e58bd7b878
Fix links to OpenGL API in docs
Those links were broken before, since the [] and () part were split
into two different lines. This also caused warnings on nightly, which
are now fixed.
2018-07-11 10:56:06 +02:00
Victor Koenders
bd88d9e93f Fixed a compiler issue with the 'simd' feature 2018-06-08 14:35:12 +02:00
Victor Koenders
cdb0e8c8a1 Bumped rand and fixed compiler issues 2018-06-08 13:39:02 +02:00
Alex Butler
a3965d414d
Update approx -> 0.2 2018-05-23 12:43:52 +01:00
Richard Dodd
2a7e2ebda3 Fix simd 2018-04-29 17:04:49 +01:00
Richard Dodd
f8e92ed327 Add is_finite to array and quaternion 2018-04-29 14:21:42 +01:00
Richard Dodd
f82e421e2c Fix for simd 2018-04-28 15:09:45 +01:00
Richard Dodd
4fede94df5 Add is_finite method to vectors and matrices.
This method is useful in debug to error early when some kind of
singularity is encountered.
2018-04-28 11:34:45 +01:00
Osspial
def53ca371 Fix some documentation 2018-03-16 16:32:46 -04:00
Osspial
34da833e39 Add map functions to points and vectors 2018-01-20 23:54:59 -05:00
Osspial
d1cd15a45b Implement ElementWise for PointN 2018-01-05 15:09:12 -05:00
Brendan Zabarauskas
574dd3b972 Run rustfmt on most files 2018-01-03 13:16:40 +11:00
Brendan Zabarauskas
68b9052be1 Remove experimantal must_use annotations 2018-01-03 12:41:43 +11:00
Aceeri
fe8ec2beb9 Fix docs for unit_z on Vector3 2017-12-03 17:57:37 -08:00
Martin Lindhe
2acb4a968a fix some typos 2017-11-19 13:30:15 +01:00
Brendan Zabarauskas
43a6b2be8c Merge pull request #426 from Osspial/point_ops
Add vector subtraction for all points
2017-10-23 23:11:41 +11:00
G. Endignoux
d1e6cc4a03 Add Matrix4::look_at_dir (fix #433). 2017-10-23 12:40:35 +02:00
Osspial
0a9c51da82 Fix incorrect operator in sub_assign impl 2017-10-06 00:20:38 -04:00