diff --git a/src/cgmath/rotation.rs b/src/cgmath/rotation.rs index 6eba8fc..91fdb47 100644 --- a/src/cgmath/rotation.rs +++ b/src/cgmath/rotation.rs @@ -20,7 +20,7 @@ use matrix::{Mat2, ToMat2}; use matrix::{Mat3, ToMat3}; use point::{Point, Point2, Point3}; use quaternion::{Quat, ToQuat}; -use ray::{Ray, Ray2, Ray3}; +use ray::Ray; use vector::{Vector, Vec2, Vec3}; /// A trait for generic rotation @@ -35,9 +35,13 @@ pub trait Rotation + ApproxEq { fn identity() -> Self; - fn rotate_point(&self, point: &P) -> P; fn rotate_vec(&self, vec: &V) -> V; + #[inline] + fn rotate_point(&self, point: &P) -> P { + Point::from_vec( &self.rotate_vec( &point.to_vec() ) ) + } + #[inline] fn rotate_ray(&self, ray: &Ray) -> Ray { Ray::new( //FIXME: use clone derived from Array @@ -115,15 +119,9 @@ impl Rotation, Point2> for Basis2 { #[inline] fn identity() -> Basis2 { Basis2{ mat: Mat2::identity() } } - #[inline] - fn rotate_point(&self, _point: &Point2) -> Point2 { fail!("Not yet implemented") } - #[inline] fn rotate_vec(&self, vec: &Vec2) -> Vec2 { self.mat.mul_v(vec) } - #[inline] - fn rotate_ray(&self, _ray: &Ray2) -> Ray2 { fail!("Not yet implemented") } - #[inline] fn concat(&self, other: &Basis2) -> Basis2 { Basis2 { mat: self.mat.mul_m(&other.mat) } } @@ -236,15 +234,9 @@ impl Rotation, Point3> for Basis3 { #[inline] fn identity() -> Basis3 { Basis3{ mat: Mat3::identity() } } - #[inline] - fn rotate_point(&self, _point: &Point3) -> Point3 { fail!("Not yet implemented") } - #[inline] fn rotate_vec(&self, vec: &Vec3) -> Vec3 { self.mat.mul_v(vec) } - #[inline] - fn rotate_ray(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented") } - #[inline] fn concat(&self, other: &Basis3) -> Basis3 { Basis3 { mat: self.mat.mul_m(&other.mat) } } @@ -298,15 +290,9 @@ impl Rotation, Point3> for Quat { #[inline] fn identity() -> Quat { Quat::identity() } - #[inline] - fn rotate_point(&self, _point: &Point3) -> Point3 { fail!("Not yet implemented") } - #[inline] fn rotate_vec(&self, vec: &Vec3) -> Vec3 { self.mul_v(vec) } - #[inline] - fn rotate_ray(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented") } - #[inline] fn concat(&self, other: &Quat) -> Quat { self.mul_q(other) }