Commit graph

186 commits

Author SHA1 Message Date
aloucks
8e0d5ece92
Fix deprecation warnings (#522) 2020-12-05 18:41:30 -05:00
Aaron Loucks
3bd348127c Remove duplicate code in the deprecated Matrix3::look_at function 2020-12-04 19:41:27 -05:00
Aaron Loucks
c0a66d2a34 Rename Matrix3::look_at_[rh|lh] to look_to_[rh|lh]
This makes the Matrix3/4 and Decomposed `look_at_*` functions consistent
with looking at a center/focus point and `look_to_*` functions consistent
with looking in a direction.
2020-12-04 19:41:27 -05:00
Aaron Loucks
213fc580a9 Add Transform::{look_at_rh, look_at_lh} and deprecate look_at
Corresponding functions have been added to Matrix4 and Decomposed
and are now consistent.

Matrix3, Matrix2, and the Rotation trait are only partially updated.
2020-12-04 19:41:27 -05: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
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
935f389983 replace deprecated try! macro by ? operator 2019-09-01 15:16:03 +02: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
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
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
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
Brendan Zabarauskas
574dd3b972 Run rustfmt on most files 2018-01-03 13:16:40 +11:00
G. Endignoux
d1e6cc4a03 Add Matrix4::look_at_dir (fix #433). 2017-10-23 12:40:35 +02:00
Osspial
a6abd5bf02 Modify cast() functions to return Option 2017-08-16 16:21:51 -04:00
Dzmitry Malyshau
d72fc08826 Mint flavour 2017-06-06 18:07:38 -04:00
Dzmitry Malyshau
7a21125c55 Refined serde dependencies 2017-06-06 16:48:55 -04:00
Dzmitry Malyshau
087336d0c0 Refinded simd feature 2017-06-06 16:44:13 -04:00
Brendan Zabarauskas
a0e370ff7b Fix matrix inversions for small determinants
Closes #210
2017-05-13 18:51:59 +10:00
kennytm
f524d40403
Workaround rust-lang/rust#41478.
Replace all `impl .. for Struct<<A as Angle>::Unitless>` by
`Struct<A::Unitless>`. This allows -Zsave-analysis to work on nightly, and
I think this is more readable too.
2017-05-02 01:15:46 +08:00
Brendan Zabarauskas
77260934a1 Clean up Sum and Product impls
This is for consistency with other impls
2017-04-26 21:56:02 +10:00
Ben Boeckel
240559b941 iter traits: impl iter::{Sum, Product}
This adds `Sum` trait for the `MatrixN`, `VectorN`, `Quaternion`
structures and the `Product` trait for `MatrixN`, `BasisN` and
`Quaternion`.

It also add constraints on the `Rotation` and `SquareMatrix` to require
the `Product` trait and `VectorSpace` to require `Sum`.
2017-04-25 11:01:18 -04:00
Brendan Zabarauskas
78555ec780 Drop rustc-serialize support
According to [Rust release milestone predictions](https://internals.rust-lang.org/t/rust-release-milestone-predictions/4591?u=dtolnay), rustc-serialize is scheduled to be deprecated in next month's beta release of Rust.

Closes #395
2017-04-16 16:35:24 +10:00
Luxko
09c8727c7c Add newline at end of file 2017-03-12 15:59:06 +08:00
Luxko
68d1d27222 Add SIMD support for determinant and inverse
Also:
- Change the travis script: no use `cargo bench`ing in beta or stable.
- Add bench test for Matrix4's determinant().
- clean code a bit
2017-02-25 20:31:38 +08:00
Luxko
d45536f1bd Clean up a bit 2017-02-25 07:42:15 +08:00
Luxko
64924b954d [WIP]Add basic SIMD support
- Add an opt-in SIMD support for the module. The feature requires crate
`simd` and specialization, thus can only be enabled under nightly. Under
the given benchmark certain operations were able to be up to 60% faster.
Currently the supported types as well as operations are highly limited.
- Clean up some deadly tests. Also add new tests for SIMD.
2017-02-25 07:26:11 +08:00
Marckvdv
d2d35b808b Added component wise casting number for the matrix and point types. 2016-10-03 12:51:41 +02:00
Mark Hintz
f475822d9b Removes #[repr(packed)] from all structs where it was specified.
This is intended as a partial fix for #375. It doesn't also remove #[repr(C)],
since it's a bit unclear whether that's necessary.
2016-08-25 15:41:39 +02:00
Andrew Dudney
0f8a96d9b8 Changed over to the approx crate. Currently breaks rotation's doc tests. 2016-08-22 09:21:22 -06:00
Andrew Dudney
17d98af64f Made uses of Rad<S> more generic using Into<Rad<S>> 2016-07-26 17:30:05 -07:00
Brendan Zabarauskas
7147180936 Merge pull request #359 from jminer/rotation-fixes
Rotation fixes
2016-05-18 00:19:43 +10:00
Romain Vaillant
cdbb9294e0 Adds serde support 2016-05-16 14:16:59 +02:00
Romain Vaillant
f3673a1d4c makes rustc-serialize optional 2016-05-15 14:48:57 +02:00
Jordan Miner
c11371794f Fix Euler angle to matrix conversion
The equations were written with rows horizontally instead of vertically
and some signs were wrong.
2016-05-12 01:28:16 -05:00
Jordan Miner
b56119a42f Test converting axis angles to quaternions 2016-05-12 01:28:15 -05:00
Mark Hintz
074cb2c36f Change the name of methods on the Transform trait to avoid clashes
Transform::invert becomes Transform::inverse_transform, and Transform::invert_self becomes Transform::to_inverse. Tests passing for me now
2016-05-01 14:59:38 +02:00
Mark Hintz
0a78173e2b impl Transform (2 dimensional) for Matrix3 2016-04-28 16:37:36 +02:00
Mark Hintz
a3539483b6 impl Transform (3 dimensional) for Matrix3 2016-04-28 16:37:36 +02:00
Mark Hintz
ab1d3d8622 imple Transform (and Transform3) for Matrix4
The change in transform.rs is to disambiguate which invert function is used
2016-04-28 16:37:36 +02:00
Mark Hintz
c32135a5d9 Move the From impls together 2016-04-28 16:37:36 +02:00
Mark Hintz
808a17fc22 implement from_angle{x, y, z} and from_axis_angle for Matrix4
All are duplicates of the same functions for Matrix3, with extra parameters added in to make up the full 4x4
2016-04-28 01:03:33 +02:00
Brendan Zabarauskas
6b48236cb6 Inherit Zero and One for core structural traits 2016-04-25 15:26:56 +10:00
Brendan Zabarauskas
54adacc2a8 Re-export Zero and One via structure module 2016-04-25 11:43:28 +10:00
Brendan Zabarauskas
0259acb87f Switch to an Euler angle type for defining rotations 2016-04-23 16:56:07 +10:00
Brendan Zabarauskas
86c13ca14f Switch to using num_traits crate from num
Fixes #336
2016-04-23 14:03:35 +10:00
Brendan Zabarauskas
8dd2874b59 Move traits into common module 2016-04-19 20:51:40 +10:00