Commit graph

649 commits

Author SHA1 Message Date
Brendan Zabarauskas 9064b9d5c0 Add some matrix impls, add operator macros 2013-08-27 16:11:05 +10:00
Brendan Zabarauskas b67b31b633 Add matrix traits, do lots of reorganisation/re-formatting 2013-08-27 08:59:18 +10:00
Brendan Zabarauskas caadaa669a Fix copyright notices 2013-08-26 15:51:19 +10:00
Brendan Zabarauskas 3673c4db6d Overhaul library, rename to cgmath
Moved the old source code temporarily to src-old. This will be removed once the functionality has been transferred over into the new system.

The new design is based on algebraic principles. Thanks goes to sebcrozet and his nalgebra library for providing the inspiration for the algebraic traits: https://github.com/sebcrozet/nalgebra
2013-08-26 15:08:25 +10:00
Brendan Zabarauskas c429ed839d Remove noise and color modules
These have now been moved to separate repositories:

  - https://github.com/bjz/noise-rs
  - https://github.com/bjz/color-rs
2013-07-30 14:02:26 +10:00
Brendan Zabarauskas 994b135bcd Rename map_as_vecN to with_vecN
This brings the method names into line with standard Rust nomenclature, for example `extra::rc::RcMut::{with_borrow, with_mut_borrow}`.
2013-07-25 15:40:10 +10:00
Brendan Zabarauskas 5fecb8fc81 Generalise noise methods to take generic Dimensioned types 2013-07-25 12:57:14 +10:00
Brendan Zabarauskas df3ce2935c Add general Dimensioned and SwapComponents impls 2013-07-25 12:55:57 +10:00
Brendan Zabarauskas 679db701c9 Impl ApproxEq for rotation matricies using macros 2013-07-25 12:38:43 +10:00
Brendan Zabarauskas f68c488163 Implement Ken Perlin's 'Improved Noise' algorithm and add example 2013-07-23 15:11:05 +10:00
Brendan Zabarauskas c206d7dc3c Rename dimensional acessors
index->i
col->c
row->r
elem->cr
2013-07-22 14:41:31 +10:00
Brendan Zabarauskas 1538e6e528 Merge quat impls 2013-07-22 14:06:35 +10:00
Brendan Zabarauskas a753602d34 Remove rotate methods, standardise some method names, add displacement method
We don't need the rotation methods now because of the types in transform::rotation
2013-07-21 15:11:25 +10:00
Brendan Zabarauskas 65aea95e7d Add scalar and component-wise clamp methods 2013-07-21 15:09:20 +10:00
Brendan Zabarauskas 31be8b79df Add map_as_vec{2,3,4} methods and document AsVec method impls
These are useful for when for reusing methods available on the Vec{2,3,4} types.
2013-07-21 13:20:28 +10:00
Brendan Zabarauskas a5c00bfe97 Use _s suffix instead of _t for methods that take scalar values
This is what rust-geom uses, and it seems to make more sense. I originally used _t because it referred to the base generic type, but I think _s makes more sense.
2013-07-19 11:10:28 +10:00
Brendan Zabarauskas 58c1fe7e1c Implement some rotation methods and fix method signatures 2013-07-16 23:36:17 +10:00
Brendan Zabarauskas bc2c26928f Add Rotation2 trait and do some documentation work 2013-07-16 10:27:31 +10:00
Brendan Zabarauskas 03bfe9b7a7 Move rotation module into transform module
This decouples these types from the more general math types. It also makes more sense, because rotations are indeed a type of transformation.
2013-07-16 09:23:57 +10:00
Brendan Zabarauskas 8d2d0d11bd Remove Matrix trait impls for RotationMat
These operations could potentially mess up the orthoganality of the rotation matrix. We could have made these fail if an the resulting matrices were not orthogonal, but it is preferable to enforce this at compile time rather than run time. More operations should be added in the future with this restriction in mind.
2013-07-16 09:20:30 +10:00
Brendan Zabarauskas 3daea27696 Add Rotation trait, RotationMat type, and implement Mat4 conversions 2013-07-16 07:57:36 +10:00
Brendan Zabarauskas aa2f9224ce Re-organise matrix constants 2013-07-16 07:14:10 +10:00
Brendan Zabarauskas e9cc75f06d Add rotation module 2013-07-15 12:03:21 +10:00
Brendan Zabarauskas 2ecc99b6a7 Documentation work 2013-07-15 12:03:03 +10:00
Brendan Zabarauskas d700a7b35f Implement min and max methods for vectors 2013-07-15 02:02:38 +10:00
Brendan Zabarauskas 4008cf8121 Implement component-wise methods 2013-07-14 16:18:25 +10:00
Brendan Zabarauskas 19376dce32 Divide vec unit tests into separate functions 2013-07-14 15:32:43 +10:00
Brendan Zabarauskas e321b1046b Documentation work 2013-07-14 14:43:29 +10:00
Brendan Zabarauskas 1810444a0a Rename Dimensioned and Swap traits 2013-07-14 13:22:45 +10:00
Brendan Zabarauskas d5514fc982 Move contents of geom and core modules into new math module
Having these two modules separate made more sense when the library was divided into lmath and cgmath. Now that the two have been combined, it makes more sense to bundle these types in one module (I think).
2013-07-14 11:47:10 +10:00
Brendan Zabarauskas 3ce6578d56 Rename RealVec to FloatVec and use Float trait constraints 2013-07-14 07:53:37 +10:00
Brendan Zabarauskas 04c24a01fa Traitify Mat methods and remove macros 2013-07-14 07:49:23 +10:00
Brendan Zabarauskas 6061395fd7 Add Vec trait that inherits from Dimensional and Swap 2013-07-14 07:48:54 +10:00
Brendan Zabarauskas d19e874b76 Remove unneccesary derefs 2013-07-14 00:55:46 +10:00
Brendan Zabarauskas 6a9d690c79 Arrange vector methods into traits 2013-07-13 23:37:38 +10:00
Brendan Zabarauskas 0e483bb579 Add some doc comments to vec module 2013-07-13 23:06:17 +10:00
Brendan Zabarauskas 139cd6dbe9 Misc formatting 2013-07-13 23:03:37 +10:00
Brendan Zabarauskas e1e6b90c1b Move types related to bounding volumes to bounds module 2013-07-13 23:00:33 +10:00
Brendan Zabarauskas 8973179b0d Add impl_to_vec! and impl_as_vec! macros and use for points and colors 2013-07-12 19:20:09 +10:00
Brendan Zabarauskas ad59c9b16f Decouple vec module from Point2 and Point3 2013-07-12 16:36:36 +10:00
Brendan Zabarauskas 7615a55d84 More module re-arrangement 2013-07-12 16:32:12 +10:00
Brendan Zabarauskas 0cbfa7d040 Remove unnecessary method impl (bools now impl Not) 2013-07-12 14:08:25 +10:00
Brendan Zabarauskas 2ed5e94710 Add ray_to method to point types 2013-07-12 14:07:21 +10:00
Brendan Zabarauskas 3d51d83c92 Rename length to magnitude and remove distance methods from vec 2013-07-12 13:42:28 +10:00
Brendan Zabarauskas eb75d34636 Add vector conversion traits 2013-07-12 13:41:28 +10:00
Brendan Zabarauskas 4159a214da Add skeleton structs and impls for noise types 2013-07-12 12:38:53 +10:00
Brendan Zabarauskas 8139e634fb Remove conflicting ApproxEq impls 2013-07-12 12:19:40 +10:00
Brendan Zabarauskas 3656068f5c Add impl_approx! macro 2013-07-12 11:22:14 +10:00
Brendan Zabarauskas f30b79deb3 Add some more types to geom and improve field names 2013-07-12 10:33:20 +10:00
Brendan Zabarauskas e6bb9362ed Create space module 2013-07-12 09:17:37 +10:00
Brendan Zabarauskas 6300d4b539 Move swap and dimensional impls into separate modules 2013-07-12 07:44:20 +10:00
Brendan Zabarauskas b06785fc89 Remove impl_approx! macro 2013-07-11 23:54:50 +10:00
Brendan Zabarauskas c4c986c0ef Remove yuv module 2013-07-11 16:41:43 +10:00
Brendan Zabarauskas 290861f952 Add conversions from points to homogenous coordinates 2013-07-11 15:14:32 +10:00
Brendan Zabarauskas de649c3b50 Add a bit of documentation to the point module 2013-07-11 14:59:18 +10:00
Brendan Zabarauskas 50747703cf Method rejiggering. Add origin method. 2013-07-11 14:49:14 +10:00
Brendan Zabarauskas 92ee628c06 Fix normalize_degrees impls 2013-07-11 13:05:29 +10:00
Brendan Zabarauskas fd9fcd2075 Add normalize_channel method 2013-07-11 12:56:35 +10:00
Brendan Zabarauskas 659226b15e Add more methods to Point trait and implement operator overloads 2013-07-11 12:19:29 +10:00
Brendan Zabarauskas aedf317af1 Add rotate method to Point trait, remove from_vec function and move impl directly on types 2013-07-11 11:45:21 +10:00
Brendan Zabarauskas f5d96ab398 Create transform module, move frustum module, add a little documentation 2013-07-11 11:11:43 +10:00
Brendan Zabarauskas 8ae7f3dbad Add rgb tests 2013-07-11 07:58:40 +10:00
Brendan Zabarauskas ff439c9b1d Comments ahoy 2013-07-10 20:46:14 +10:00
Brendan Zabarauskas 0d24a87a8e Add svg color constants 2013-07-10 20:45:42 +10:00
Brendan Zabarauskas 1188cba878 Fix build error 2013-07-10 20:14:11 +10:00
Brendan Zabarauskas 8bca8757c2 Add hsv conversion tests 2013-07-10 20:13:50 +10:00
Brendan Zabarauskas 49b9b85079 Add yuv and ycbcr skeleton modules 2013-07-10 15:51:05 +10:00
Brendan Zabarauskas 053586c8e2 Add point conversion methods for vec2 and vec3 types 2013-07-10 14:18:44 +10:00
Brendan Zabarauskas e12f561930 Add channel and color normalization methods 2013-07-10 14:16:16 +10:00
Brendan Zabarauskas 58c3233fe3 Impl Color trait 2013-07-10 12:59:02 +10:00
Brendan Zabarauskas a3f997e763 Make Channel::from private 2013-07-10 10:59:23 +10:00
Brendan Zabarauskas 290287a0b9 Add skeleton hex conversions 2013-07-10 10:58:55 +10:00
Brendan Zabarauskas 8adad636d1 Add RGBA and HSVA impls 2013-07-10 10:57:37 +10:00
Brendan Zabarauskas 7e70e826f2 Add generic to_channel method 2013-07-10 10:37:59 +10:00
Brendan Zabarauskas c4728af209 Add channel tests 2013-07-10 00:06:14 +10:00
Brendan Zabarauskas 23e21ac1b3 Improve trait bounds 2013-07-09 23:10:59 +10:00
Brendan Zabarauskas d65aa944b9 Simplify color::channel traits 2013-07-09 22:50:20 +10:00
Brendan Zabarauskas 49715e6479 Merge some color modules 2013-07-09 21:28:23 +10:00
Brendan Zabarauskas 29a99cea51 Reduce transmute ugliness 2013-07-09 21:17:04 +10:00
Brendan Zabarauskas 452decd3e2 Use upper case identifiers for static constants 2013-07-09 17:32:24 +10:00
Brendan Zabarauskas 128e645a20 Relax type bounds 2013-07-09 17:05:19 +10:00
Brendan Zabarauskas b9369247bf Remove free standing color conversion functions 2013-07-09 16:53:24 +10:00
Brendan Zabarauskas afaa3af501 Re-export FrustumPoints from world module 2013-07-09 16:44:15 +10:00
Brendan Zabarauskas 5c3197a7fc Rename Plane to Plane3 for consistency with other types 2013-07-09 16:43:33 +10:00
Brendan Zabarauskas 2ca90cb750 Fix color channel conversions 2013-07-09 16:42:19 +10:00
Brendan Zabarauskas a5d4fc1ed4 Make point into standalone struct as opposed to a newtype struct 2013-07-08 18:17:36 +10:00
Brendan Zabarauskas 5b5d1f38b3 Add octree and quadtree mods (not yet implemented) 2013-07-08 17:48:11 +10:00
Brendan Zabarauskas 999782945c Add color module 2013-07-08 17:39:33 +10:00
Brendan Zabarauskas 6925c5eaad Add skeleton noise module 2013-07-08 17:04:48 +10:00
Brendan Zabarauskas c0a5b29af1 Move files into submodules 2013-07-08 17:02:04 +10:00
Brendan Zabarauskas 288afe0898 Remove dimensional HOFs 2013-07-08 13:20:34 +10:00
Brendan Zabarauskas c91b0747b3 Untangle mat macros 2013-07-04 10:59:21 +10:00
Brendan Zabarauskas 1819846a4c Untangle vec macros 2013-07-01 13:25:45 +10:00
Brendan Zabarauskas b7530c3512 Fix lifetime error 2013-07-01 11:39:13 +10:00
maikklein d43629e2b9 fixes += operator etc 2013-06-30 18:28:39 +02:00
Brendan Zabarauskas 6fb6d57175 Use the Clone trait instead of Copy and switch from the copy keyword to calling the clone method.
impl_approx! is broken with a borrow issue. The library does not compile yet. Sorry!
2013-06-29 16:38:55 +10:00
maikklein c36cb6e555 explicit copy 2013-06-29 02:26:26 +02:00
maikklein 547ac400fd explicit copy 2013-06-29 02:25:07 +02:00
Brendan Zabarauskas 6cfb244b41 Merge vector and matrix source files 2013-06-16 18:03:14 +10:00
Brendan Zabarauskas 9d99347bbf Add types from cgmath 2013-06-16 17:34:09 +10:00
Brendan Zabarauskas 11e1623dad Rename macros file 2013-06-16 17:32:48 +10:00
Brendan Zabarauskas f5ba7a7982 Remove duplicate Dimensional trait definition 2013-06-16 15:37:30 +10:00
Brendan Zabarauskas a4c7332e2b Move Dimensional trait and dimensional macros into separate files 2013-06-16 15:34:59 +10:00
Brendan Zabarauskas f20eca5cc5 Use macros and higher-order functions to reduce code repetition 2013-06-16 15:21:32 +10:00
maikklein 8673cd6701 Fixing vec2.perp_dot and vec3.angle 2013-06-16 02:08:16 +02:00
Brendan Zabarauskas e82ac511a5 Use higher order functions to reduce code repetition in some methods 2013-06-12 15:49:54 +10:00
Brendan Zabarauskas b727dd2bf5 Implement Dimensional trait 2013-06-12 12:57:58 +10:00
Brendan Zabarauskas 5cb98d09cf Add conversion traits 2013-06-12 11:30:18 +10:00
Brendan Zabarauskas b2e7f2e4b1 Some constructors and functions don't need T:Copy 2013-06-12 11:15:12 +10:00
Brendan Zabarauskas feb4ae2a00 Move tests into source files 2013-06-12 11:02:11 +10:00
Brendan Zabarauskas f226ab2262 Re-organise modules 2013-06-12 10:02:39 +10:00
Brendan Zabarauskas 21ae345adc Be more selective about inlining, #[inline(always)] -> #[inline] for functions other than map 2013-06-12 07:50:16 +10:00
Brendan Zabarauskas 17975b798d De-traitify types, fix tests 2013-06-11 09:02:25 +10:00
Brendan Zabarauskas 3721167cdc Fix std imports 2013-06-06 12:38:23 +10:00
Brendan Zabarauskas 288c49b474 Remove broken macros 2013-06-06 12:38:03 +10:00
Brendan Zabarauskas d352577356 Use /// style doc comments 2013-06-01 12:57:29 +10:00
Brendan Zabarauskas f443203d4a Create elem and elem_mut methods for accessing matrix elements 2013-06-01 11:56:11 +10:00
Brendan Zabarauskas a485920354 Fix constructors, tests now pass (YAYAY!)
YAYYYYYYYYAYAYAYAYAYAYAY

*jumps for joy*
2013-06-01 11:07:25 +10:00
Brendan Zabarauskas 36039228b6 Don't use index operator in tests 2013-06-01 09:12:30 +10:00
Brendan Zabarauskas a913be0373 Delete old files 2013-06-01 08:01:20 +10:00
Brendan Zabarauskas d3bfcc194e Add license/copyright notices to source files 2013-06-01 08:01:01 +10:00
Brendan Zabarauskas e630faf239 Remove index operator impls to prevent copying
We could re-implement this once the Index trait has been improved
2013-05-31 21:42:46 +10:00
Brendan Zabarauskas 86241f69cb Fix multiple borrow errors 2013-05-24 07:55:23 +10:00
Brendan Zabarauskas f800a0ae04 Fixes for core->std and changes to use 2013-05-24 07:05:25 +10:00
Brendan Zabarauskas 0361be55c5 Simplify index methods 2013-05-22 17:01:52 +10:00
Brendan Zabarauskas 11d6d0259a Use #[cfg(test)] instead of #[test]. 2013-05-22 16:46:27 +10:00
Brendan Zabarauskas 0c1af624a7 Remove usages of the <-> operator 2013-05-22 15:44:54 +10:00
Brendan Zabarauskas ebf6a9529d Use the new ApproxEq trait in core 2013-05-08 01:00:06 +10:00
Brendan Zabarauskas 0cb3314bf8 Use the new core::num traits and remove numeric dependency 2013-05-06 13:52:22 +10:00
Brendan Zabarauskas a6acab93c3 Simplify trait bounds
Requires the latest version of numeric
2013-04-15 07:09:43 +10:00
Brendan Zabarauskas aad2d62f37 Make lifetimes explicit, as required in latest updates to rust 2013-04-15 06:43:21 +10:00
Brendan Zabarauskas 887544b0b2 Fix ortho 2013-04-07 23:18:32 +10:00
Brendan Zabarauskas a57935ccea Clean up 'orthographic' function and rename to 'ortho' 2013-04-07 23:04:54 +10:00
Mikko Perttunen 4293d9aa1b Add function projection::orthographic. 2013-04-07 13:06:26 +03:00
Mikko Perttunen 5cf091656d Fix projection::perspective. 2013-04-07 12:55:03 +03:00
Brendan Zabarauskas 9116917607 Make trait names more succinct 2013-04-02 16:12:13 +11:00
Brendan Zabarauskas 4614930ad3 Formatting 2013-04-02 15:01:38 +11:00
Brendan Zabarauskas c906578c69 Remove NumCast type parameters
The NumCast type parameter is no longer needed as it is a constraint of numeric::Number
2013-04-02 11:59:33 +11:00
Brendan Zabarauskas d2885fea52 Remove unnecessary imports 2013-04-02 11:57:58 +11:00
Brendan Zabarauskas 449705b760 Use core::num::{Zero, One, NumCast} traits for 'zero', 'one' and 'cast' methods 2013-04-02 11:25:05 +11:00
Brendan Zabarauskas 25c70a7e87 Create zip macros for automating repetitive code 2013-04-01 07:35:09 +11:00
Brendan Zabarauskas e5879db08c Use macro for generating wrapper impls 2013-03-31 22:02:36 +11:00
Brendan Zabarauskas 69615bee12 Fix unit test build 2013-03-31 22:01:50 +11:00
Brendan Zabarauskas 85e8677c9c Combine vec*.rs and mat*.rs files into two respective modules
I hate to do this as I find huge long files annoying, but it'll help work around some weird export bugs.
2013-03-31 17:27:59 +11:00
Brendan Zabarauskas a1f0980688 Remove imports from top of files 2013-03-30 23:36:34 +11:00
Brendan Zabarauskas dfa4339912 Remove unused imports 2013-03-30 11:42:55 +11:00
Brendan Zabarauskas 4b61cca057 Capitalise rustic type aliases 2013-03-30 11:22:59 +11:00
Brendan Zabarauskas 9f7d10a580 Convert type alias comments to doc comments 2013-03-30 11:22:32 +11:00
Brendan Zabarauskas a601881dd5 Add rustpkg support 2013-03-30 09:54:05 +11:00
Brendan Zabarauskas c6c92dc3e3 Merge each mutable trait with its respective immutable trait 2013-03-29 22:51:34 +11:00