Skip to content

Commit 01e88f9

Browse files
committed
Release v0.4.0 + added changelog.
Changelog: * The `Real` trait now includes some commonly implemented markers, e.g., Sync, Any, 'static, etc. * The `Module` trait no longer inherit from operator overload traits. This is due to a [limitation](rust-lang/rust#37883) in the compiler that prevent them from being used properly in generic code. * The `Transform` trait is split into `Transform` and `ProjectiveTransform`. Inverse transformation methods have been moved from the first to the second. * The `Affine` trait now has methods for appending/prepending pure translation/rotation/scaling. * `EuclideanSpace::Vector` has been renamed `EuclideanSpace::Coordinates`. * Added `Rotation::scaled_rotation_between` wich is a combination of `Rotation::rotation_between` and `Rotation::powf`. * `FiniteDimVectorSpace` looses `::component` but gains the `::component_unchecked_mut` method (for mutable compoent borrowing without bound-checking). * Added `EuclideanSpace::from_coordinates` that builds a point from its coordinates.
1 parent 12b19fe commit 01e88f9

File tree

9 files changed

+261
-90
lines changed

9 files changed

+261
-90
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Change Log
2+
All notable changes to `alga`, starting with the version 0.4.0 will be
3+
documented here.
4+
5+
This project adheres to [Semantic Versioning](http://semver.org/).
6+
7+
## [0.4.0] - WIP
8+
* The `Real` trait now includes some commonly implemented markers, e.g.,
9+
Sync, Any, 'static, etc.
10+
* The `Module` trait no longer inherit from operator overload traits. This is
11+
due to a [limitation](https://github.com/rust-lang/rust/issues/37883) in
12+
the compiler that prevent them from being used properly in generic code.
13+
* The `Transform` trait is split into `Transform` and `ProjectiveTransform`.
14+
Inverse transformation methods have been moved from the first to the second.
15+
* The `Affine` trait now has methods for appending/prepending pure
16+
translation/rotation/scaling.
17+
* `EuclideanSpace::Vector` has been renamed `EuclideanSpace::Coordinates`.
18+
* Added `Rotation::scaled_rotation_between` wich is a combination of
19+
`Rotation::rotation_between` and `Rotation::powf`.
20+
* `FiniteDimVectorSpace` looses `::component` but gains the
21+
`::component_unchecked_mut` method (for mutable compoent borrowing without
22+
bound-checking).
23+
* Added `EuclideanSpace::from_coordinates` that builds a point from its
24+
coordinates.
25+
26+

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "alga"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors = ["Brendan Zabarauskas", "Darin Morrison", "Sébastien Crozet"]
55
description = "Abstract algebra for Rust"
66
keywords = ["algebra", "monoids", "math"]

src/general/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
//! commutativity
7373
//! |
7474
//! V
75-
//! AbstractGroupAbelian
75+
//! AbstractGroupAbelian
7676
//! ~~~
7777
//!
7878
//! The following traits are provided:

src/general/real.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
use num::{Num, FromPrimitive};
1+
use std::any::Any;
2+
use num::{Num, FromPrimitive, Signed, Bounded};
23
use std::{f32, f64};
4+
use std::fmt::{Debug, Display};
35
use std::ops::{Neg, AddAssign, MulAssign, SubAssign, DivAssign};
46

57
use approx::ApproxEq;
68

7-
use general::{Field, SubsetOf, SupersetOf};
9+
use general::{Field, SubsetOf, SupersetOf, Lattice};
810

911
#[allow(missing_docs)]
1012

@@ -16,7 +18,9 @@ use general::{Field, SubsetOf, SupersetOf};
1618
// allow a blancket impl: impl<T: Clone> SubsetOf<T> for T { ... }
1719
pub trait Real: SubsetOf<Self> + SupersetOf<f64> + Field + Copy + Num + FromPrimitive +
1820
Neg<Output = Self> + AddAssign + MulAssign + SubAssign + DivAssign +
19-
ApproxEq<Epsilon = Self> + PartialOrd {
21+
ApproxEq<Epsilon = Self> + Lattice + PartialEq + Signed +
22+
Send + Sync + Any + 'static + Debug + Display + // NOTE: make all types debuggable/'static/Any ? This seems essencial for any kind of generic programming.
23+
Bounded { // NOTE: a real must be bounded because, no matter the chosen representation, being `Copy` implies that it occupies a statically-known size, meaning that it must have min/max values.
2024
fn floor(self) -> Self;
2125
fn ceil(self) -> Self;
2226
fn round(self) -> Self;

src/general/specialized.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ specialize_structures!(Field, AbstractField: RingCommutative
4444

4545
/// A module which overloads the `*` and `+` operators.
4646
pub trait Module: AbstractModule<AbstractRing = <Self as Module>::Ring> +
47-
ClosedMul<<Self as Module>::Ring> {
47+
AdditiveGroupAbelian /* +
48+
ClosedMul<<Self as Module>::Ring>
49+
*/ {
4850
/// The underlying scalar field.
4951
type Ring: RingCommutative;
5052
}

src/linear/id.rs

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use num;
22

33
use general::{Identity, Id};
44
use linear::{InnerSpace, EuclideanSpace, Transformation, AffineTransformation, Scaling, Similarity,
5-
Isometry, DirectIsometry, OrthogonalTransformation, Translation, Rotation};
5+
Isometry, DirectIsometry, OrthogonalTransformation, Translation, Rotation,
6+
ProjectiveTransformation};
67

78
/*
89
* Implementation of linear algebra structures for the ubiquitous identity element.
@@ -14,35 +15,65 @@ impl<E: EuclideanSpace> Transformation<E> for Id {
1415
}
1516

1617
#[inline]
17-
fn transform_vector(&self, v: &E::Vector) -> E::Vector {
18+
fn transform_vector(&self, v: &E::Coordinates) -> E::Coordinates {
1819
v.clone()
1920
}
21+
}
2022

23+
impl<E: EuclideanSpace> ProjectiveTransformation<E> for Id {
2124
#[inline]
2225
fn inverse_transform_point(&self, pt: &E) -> E {
2326
pt.clone()
2427
}
2528

2629
#[inline]
27-
fn inverse_transform_vector(&self, v: &E::Vector) -> E::Vector {
30+
fn inverse_transform_vector(&self, v: &E::Coordinates) -> E::Coordinates {
2831
v.clone()
2932
}
3033
}
3134

3235
impl<E: EuclideanSpace> AffineTransformation<E> for Id {
33-
type PreRotation = Id;
36+
type Rotation = Id;
3437
type NonUniformScaling = Id;
35-
type PostRotation = Id;
3638
type Translation = Id;
3739

3840
#[inline]
3941
fn decompose(&self) -> (Id, Id, Id, Id) {
4042
(Id::new(), Id::new(), Id::new(), Id::new())
4143
}
44+
45+
#[inline]
46+
fn append_translation(&self, _: &Self::Translation) -> Self {
47+
*self
48+
}
49+
50+
#[inline]
51+
fn prepend_translation(&self, _: &Self::Translation) -> Self {
52+
*self
53+
}
54+
55+
#[inline]
56+
fn append_rotation(&self, _: &Self::Rotation) -> Self {
57+
*self
58+
}
59+
60+
#[inline]
61+
fn prepend_rotation(&self, _: &Self::Rotation) -> Self {
62+
*self
63+
}
64+
65+
#[inline]
66+
fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self {
67+
*self
68+
}
69+
70+
#[inline]
71+
fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self {
72+
*self
73+
}
4274
}
4375

4476
impl<E: EuclideanSpace> Similarity<E> for Id {
45-
type Rotation = Id;
4677
type Scaling = Id;
4778

4879
#[inline]
@@ -74,25 +105,30 @@ impl<E: EuclideanSpace> Rotation<E> for Id {
74105
}
75106

76107
#[inline]
77-
fn rotation_between(a: &E::Vector, b: &E::Vector) -> Option<Self> {
108+
fn rotation_between(a: &E::Coordinates, b: &E::Coordinates) -> Option<Self> {
78109
if a.angle(b) == num::zero() {
79110
Some(Id::new())
80111
}
81112
else {
82113
None
83114
}
84115
}
116+
117+
#[inline]
118+
fn scaled_rotation_between(a: &E::Coordinates, b: &E::Coordinates, _: E::Real) -> Option<Self> {
119+
Rotation::<E>::rotation_between(a, b)
120+
}
85121
}
86122

87123
impl<E: EuclideanSpace> Translation<E> for Id {
88124
#[inline]
89-
fn to_vector(&self) -> E::Vector {
90-
E::Vector::identity()
125+
fn to_vector(&self) -> E::Coordinates {
126+
E::Coordinates::identity()
91127
}
92128

93129
#[inline]
94-
fn from_vector(v: &E::Vector) -> Option<Self> {
95-
if *v == E::Vector::identity() {
130+
fn from_vector(v: E::Coordinates) -> Option<Self> {
131+
if v == E::Coordinates::identity() {
96132
Some(Id::new())
97133
}
98134
else {

src/linear/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
pub use self::vector::{VectorSpace, NormedSpace, InnerSpace, FiniteDimVectorSpace, FiniteDimInnerSpace,
44
AffineSpace, EuclideanSpace};
55
pub use self::transformation::{Transformation, AffineTransformation, Scaling, Similarity, Isometry,
6-
DirectIsometry, Translation, OrthogonalTransformation, Rotation};
6+
DirectIsometry, Translation, OrthogonalTransformation, Rotation,
7+
ProjectiveTransformation};
78
pub use self::matrix::{Matrix, MatrixMut, SquareMatrix, SquareMatrixMut, InversibleSquareMatrix};
89

910
mod vector;

0 commit comments

Comments
 (0)