diff --git a/src/matrix.rs b/src/matrix.rs index e509dd2..032dfc6 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -29,7 +29,7 @@ use angle::{Angle, Rad}; use approx::ApproxEq; use array::Array; use num::BaseFloat; -use point::{Point, Point3}; +use point::{EuclideanSpace, Point3}; use quaternion::Quaternion; use vector::{VectorSpace, InnerSpace}; use vector::{Vector2, Vector3, Vector4}; diff --git a/src/point.rs b/src/point.rs index 42dad62..40eb355 100644 --- a/src/point.rs +++ b/src/point.rs @@ -116,25 +116,25 @@ impl Point3 { /// ## Converting between points and vectors /// /// Points can be converted to and from displacement vectors using the -/// `Point::{from_vec, to_vec}` methods. Note that under the hood these are -/// implemented as inlined a type conversion, so should not have any performance -/// implications. +/// `EuclideanSpace::{from_vec, to_vec}` methods. Note that under the hood these +/// are implemented as inlined a type conversion, so should not have any +/// performance implications. /// /// ## References /// /// - [CGAL 4.7 - 2D and 3D Linear Geometry Kernel: 3.1 Points and Vectors](http://doc.cgal.org/latest/Kernel_23/index.html#Kernel_23PointsandVectors) /// - [What is the difference between a point and a vector](http://math.stackexchange.com/q/645827) /// -pub trait Point: Copy + Clone where +pub trait EuclideanSpace: Copy + Clone where // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 - Self: Array::Scalar>, + Self: Array::Scalar>, - Self: Add<::Diff, Output = Self>, - Self: Sub::Diff>, + Self: Add<::Diff, Output = Self>, + Self: Sub::Diff>, - Self: Mul<::Scalar, Output = Self>, - Self: Div<::Scalar, Output = Self>, - Self: Rem<::Scalar, Output = Self>, + Self: Mul<::Scalar, Output = Self>, + Self: Div<::Scalar, Output = Self>, + Self: Rem<::Scalar, Output = Self>, { /// The associated scalar over which the space is defined. /// @@ -195,7 +195,7 @@ macro_rules! impl_point { } } - impl Point for $PointN { + impl EuclideanSpace for $PointN { type Scalar = S; type Diff = $VectorN; diff --git a/src/prelude.rs b/src/prelude.rs index 1378f96..7275976 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -10,7 +10,7 @@ pub use array::ElementWise; pub use matrix::Matrix; pub use matrix::SquareMatrix; -pub use point::Point; +pub use point::EuclideanSpace; pub use rotation::Rotation; pub use rotation::Rotation2; diff --git a/src/rotation.rs b/src/rotation.rs index dd010a8..2f844b7 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -20,16 +20,16 @@ use approx::ApproxEq; use matrix::SquareMatrix; use matrix::{Matrix2, Matrix3}; use num::BaseFloat; -use point::{Point, Point2, Point3}; +use point::{EuclideanSpace, Point2, Point3}; use quaternion::Quaternion; use vector::{InnerSpace, Vector2, Vector3}; /// A trait for a generic rotation. A rotation is a transformation that /// creates a circular motion, and preserves at least one point in the space. -pub trait Rotation: PartialEq + Sized where +pub trait Rotation: PartialEq + Sized where // FIXME: Ugly type signatures - blocked by rust-lang/rust#24092 - Self: ApproxEq::Scalar>, -

::Scalar: BaseFloat, + Self: ApproxEq::Scalar>, +

::Scalar: BaseFloat, { /// Create the identity transform (causes no transformation). fn one() -> Self; diff --git a/src/transform.rs b/src/transform.rs index 9939a47..66ad4e5 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -27,7 +27,7 @@ use vector::*; /// A trait representing an [affine /// transformation](https://en.wikipedia.org/wiki/Affine_transformation) that /// can be applied to points or vectors. An affine transformation is one which -pub trait Transform: Sized { +pub trait Transform: Sized { /// Create an identity transformation. That is, a transformation which /// does nothing. fn one() -> Self; @@ -78,16 +78,16 @@ 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, +

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

::Diff: VectorSpace, +

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

::Scalar::one(), + scale:

::Scalar::one(), rot: R::one(), disp: P::Diff::zero(), } @@ -98,7 +98,7 @@ impl> Transform

for Decomposed where let rot = R::look_at(center - eye, up); let disp = rot.rotate_vector(P::origin() - eye); Decomposed { - scale:

::Scalar::one(), + scale:

::Scalar::one(), rot: rot, disp: disp, } @@ -123,10 +123,10 @@ impl> Transform

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

::Scalar::zero()) { + if self.scale.approx_eq(&

::Scalar::zero()) { None } else { - let s =

::Scalar::one() / self.scale; + let s =

::Scalar::one() / self.scale; let r = self.rot.invert(); let d = r.rotate_vector(self.disp.clone()) * -s; Some(Decomposed {