diff --git a/src/point.rs b/src/point.rs index a16059b..42dad62 100644 --- a/src/point.rs +++ b/src/point.rs @@ -79,7 +79,7 @@ impl Point3 { } /// Points in a [Euclidean space](https://en.wikipedia.org/wiki/Euclidean_space) -/// with an associated vector space, `Self::Vector`. +/// with an associated space of displacement vectors. /// /// # Point-Vector distinction /// @@ -129,21 +129,21 @@ pub trait Point: Copy + Clone where // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 Self: Array::Scalar>, - Self: Add<::Vector, Output = Self>, - Self: Sub::Vector>, + Self: Add<::Diff, Output = Self>, + Self: Sub::Diff>, Self: Mul<::Scalar, Output = Self>, Self: Div<::Scalar, Output = Self>, Self: Rem<::Scalar, Output = Self>, { - /// The associated scalar. + /// The associated scalar over which the space is defined. /// - /// Due to the equality constraints demanded by `Self::Vector`, this is effectively just an - /// alias to `Self::Vector::Scalar`. + /// Due to the equality constraints demanded by `Self::Diff`, this is effectively just an + /// alias to `Self::Diff::Scalar`. type Scalar: BaseNum; /// The associated space of displacement vectors. - type Vector: VectorSpace; + type Diff: VectorSpace; /// The point at the origin of the Euclidean space. fn origin() -> Self; @@ -152,16 +152,16 @@ pub trait Point: Copy + Clone where /// /// This can be considered equivalent to the addition of the displacement /// vector `v` to to `Self::origin()`. - fn from_vec(v: Self::Vector) -> Self; + fn from_vec(v: Self::Diff) -> Self; /// Convert a point to a displacement vector. /// /// This can be seen as equivalent to the displacement vector from /// `Self::origin()` to `self`. - fn to_vec(self) -> Self::Vector; + fn to_vec(self) -> Self::Diff; /// This is a weird one, but its useful for plane calculations. - fn dot(self, v: Self::Vector) -> Self::Scalar; + fn dot(self, v: Self::Diff) -> Self::Scalar; } macro_rules! impl_point { @@ -197,7 +197,7 @@ macro_rules! impl_point { impl Point for $PointN { type Scalar = S; - type Vector = $VectorN; + type Diff = $VectorN; #[inline] fn origin() -> $PointN { diff --git a/src/rotation.rs b/src/rotation.rs index bff231c..dd010a8 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -35,14 +35,14 @@ pub trait Rotation: PartialEq + Sized where fn one() -> Self; /// Create a rotation to a given direction with an 'up' vector - fn look_at(dir: P::Vector, up: P::Vector) -> Self; + fn look_at(dir: P::Diff, up: P::Diff) -> Self; /// Create a shortest rotation to transform vector 'a' into 'b'. /// Both given vectors are assumed to have unit length. - fn between_vectors(a: P::Vector, b: P::Vector) -> Self; + fn between_vectors(a: P::Diff, b: P::Diff) -> Self; /// Rotate a vector using this rotation. - fn rotate_vector(&self, vec: P::Vector) -> P::Vector; + fn rotate_vector(&self, vec: P::Diff) -> P::Diff; /// Rotate a point using this rotation, by converting it to its /// representation as a vector. diff --git a/src/transform.rs b/src/transform.rs index 7896c8f..9939a47 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -34,17 +34,17 @@ pub trait Transform: Sized { /// Create a transformation that rotates a vector to look at `center` from /// `eye`, using `up` for orientation. - fn look_at(eye: P, center: P, up: P::Vector) -> Self; + fn look_at(eye: P, center: P, up: P::Diff) -> Self; /// Transform a vector using this transform. - fn transform_vector(&self, vec: P::Vector) -> P::Vector; + fn transform_vector(&self, vec: P::Diff) -> P::Diff; /// Transform a point using this transform. fn transform_point(&self, point: P) -> P; /// Transform a vector as a point using this transform. #[inline] - fn transform_as_point(&self, vec: P::Vector) -> P::Vector { + fn transform_as_point(&self, vec: P::Diff) -> P::Diff { self.transform_point(P::from_vec(vec)).to_vec() } @@ -78,23 +78,23 @@ pub struct Decomposed { pub disp: V, } -impl> Transform

for Decomposed where +impl> Transform

for Decomposed where // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092

::Scalar: BaseFloat, // FIXME: Investigate why this is needed! -

::Vector: VectorSpace, +

::Diff: VectorSpace, { #[inline] - fn one() -> Decomposed { + fn one() -> Decomposed { Decomposed { scale:

::Scalar::one(), rot: R::one(), - disp: P::Vector::zero(), + disp: P::Diff::zero(), } } #[inline] - fn look_at(eye: P, center: P, up: P::Vector) -> Decomposed { + fn look_at(eye: P, center: P, up: P::Diff) -> Decomposed { let rot = R::look_at(center - eye, up); let disp = rot.rotate_vector(P::origin() - eye); Decomposed { @@ -105,7 +105,7 @@ impl> Transform

for Decomposed where } #[inline] - fn transform_vector(&self, vec: P::Vector) -> P::Vector { + fn transform_vector(&self, vec: P::Diff) -> P::Diff { self.rot.rotate_vector(vec * self.scale) } @@ -114,7 +114,7 @@ impl> Transform

for Decomposed where self.rot.rotate_point(point * self.scale) + self.disp } - fn concat(&self, other: &Decomposed) -> Decomposed { + fn concat(&self, other: &Decomposed) -> Decomposed { Decomposed { scale: self.scale * other.scale, rot: self.rot.concat(&other.rot), @@ -122,7 +122,7 @@ impl> Transform

for Decomposed where } } - fn invert(&self) -> Option> { + fn invert(&self) -> Option> { if self.scale.approx_eq(&

::Scalar::zero()) { None } else {