diff --git a/src/transform/rotation.rs b/src/transform/rotation.rs index 434f9fd..041e30b 100644 --- a/src/transform/rotation.rs +++ b/src/transform/rotation.rs @@ -41,8 +41,8 @@ pub trait Rotation2: Eq + ApproxEq + ToMat2 { pub fn rotate_point2(&self, point: Point2) -> Point2; - pub fn rotate_vec2(&self, vec: Vec2) -> Point2; - pub fn rotate_ray2(&self, vec: Ray2) -> Ray2; + pub fn rotate_vec2(&self, vec: &Vec2) -> Vec2; + pub fn rotate_ray2(&self, ray: &Ray2) -> Ray2; pub fn to_rotation_mat2(&self) -> RotationMat2; } @@ -53,8 +53,8 @@ pub trait Rotation3: Eq + ToMat4 + ToQuat { pub fn rotate_point3(&self, point: Point3) -> Point3; - pub fn rotate_vec3(&self, vec: Vec3) -> Point3; - pub fn rotate_ray3(&self, vec: Ray3) -> Ray3; + pub fn rotate_vec3(&self, vec: &Vec3) -> Vec3; + pub fn rotate_ray3(&self, ray: &Ray3) -> Ray3; pub fn to_rotation_mat3(&self) -> RotationMat3; } @@ -76,16 +76,16 @@ impl RotationMat2 { } } -impl Rotation2 for RotationMat2 { - pub fn rotate_point2(&self, _point: Point2) -> Point2 { - fail!("Not yet implemented.") +impl Rotation2 for RotationMat2 { + pub fn rotate_point2(&self, point: Point2) -> Point2 { + Point2::from_vec2(self.mat.mul_v(point.as_vec2())) } - pub fn rotate_vec2(&self, _vec: Vec2) -> Point2 { - fail!("Not yet implemented.") + pub fn rotate_vec2(&self, vec: &Vec2) -> Vec2 { + self.mat.mul_v(vec) } - pub fn rotate_ray2(&self, _vec: Ray2) -> Ray2 { + pub fn rotate_ray2(&self, _ray: &Ray2) -> Ray2 { fail!("Not yet implemented.") } @@ -136,16 +136,16 @@ impl> ApproxEq for RotationMat2 { } -impl Rotation3 for Quat { - pub fn rotate_point3(&self, _point: Point3) -> Point3 { - fail!("Not yet implemented.") +impl Rotation3 for Quat { + pub fn rotate_point3(&self, point: Point3) -> Point3 { + Point3::from_vec3(self.mul_v(point.as_vec3())) } - pub fn rotate_vec3(&self, _vec: Vec3) -> Point3 { - fail!("Not yet implemented.") + pub fn rotate_vec3(&self, vec: &Vec3) -> Vec3 { + self.mul_v(vec) } - pub fn rotate_ray3(&self, _vec: Ray3) -> Ray3 { + pub fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented.") } @@ -173,16 +173,16 @@ impl RotationMat3 { } } -impl Rotation3 for RotationMat3 { - pub fn rotate_point3(&self, _point: Point3) -> Point3 { - fail!("Not yet implemented.") +impl Rotation3 for RotationMat3 { + pub fn rotate_point3(&self, point: Point3) -> Point3 { + Point3::from_vec3(self.mat.mul_v(point.as_vec3())) } - pub fn rotate_vec3(&self, _vec: Vec3) -> Point3 { - fail!("Not yet implemented.") + pub fn rotate_vec3(&self, vec: &Vec3) -> Vec3 { + self.mat.mul_v(vec) } - pub fn rotate_ray3(&self, _vec: Ray3) -> Ray3 { + pub fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented.") } @@ -273,16 +273,16 @@ impl Euler { } } -impl Rotation3 for Euler { +impl Rotation3 for Euler { pub fn rotate_point3(&self, _point: Point3) -> Point3 { fail!("Not yet implemented.") } - pub fn rotate_vec3(&self, _vec: Vec3) -> Point3 { + pub fn rotate_vec3(&self, _vec: &Vec3) -> Vec3 { fail!("Not yet implemented.") } - pub fn rotate_ray3(&self, _vec: Ray3) -> Ray3 { + pub fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented.") } @@ -372,11 +372,11 @@ impl Rotation3 for AxisAngle { fail!("Not yet implemented.") } - pub fn rotate_vec3(&self, _vec: Vec3) -> Point3 { + pub fn rotate_vec3(&self, _vec: &Vec3) -> Vec3 { fail!("Not yet implemented.") } - pub fn rotate_ray3(&self, _vec: Ray3) -> Ray3 { + pub fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented.") } @@ -464,16 +464,16 @@ pub struct AngleX(T); impl_approx!(AngleX) -impl Rotation3 for AngleX { +impl Rotation3 for AngleX { pub fn rotate_point3(&self, _point: Point3) -> Point3 { fail!("Not yet implemented.") } - pub fn rotate_vec3(&self, _vec: Vec3) -> Point3 { + pub fn rotate_vec3(&self, _vec: &Vec3) -> Vec3 { fail!("Not yet implemented.") } - pub fn rotate_ray3(&self, _vec: Ray3) -> Ray3 { + pub fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented.") } @@ -525,16 +525,16 @@ pub struct AngleY(T); impl_approx!(AngleY) -impl Rotation3 for AngleY { +impl Rotation3 for AngleY { pub fn rotate_point3(&self, _point: Point3) -> Point3 { fail!("Not yet implemented.") } - pub fn rotate_vec3(&self, _vec: Vec3) -> Point3 { + pub fn rotate_vec3(&self, _vec: &Vec3) -> Vec3 { fail!("Not yet implemented.") } - pub fn rotate_ray3(&self, _vec: Ray3) -> Ray3 { + pub fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented.") } @@ -591,30 +591,30 @@ impl Rotation2 for AngleZ { fail!("Not yet implemented.") } - pub fn rotate_vec2(&self, _vec: Vec2) -> Point2 { + pub fn rotate_vec2(&self, _vec: &Vec2) -> Vec2 { fail!("Not yet implemented.") } - pub fn rotate_ray2(&self, _vec: Ray2) -> Ray2 { + pub fn rotate_ray2(&self, _ray: &Ray2) -> Ray2 { fail!("Not yet implemented.") } #[inline] pub fn to_rotation_mat2(&self) -> RotationMat2 { - RotationMat2 { mat: self.to_mat2() } + fail!("Not yet implemented.") } } -impl Rotation3 for AngleZ { +impl Rotation3 for AngleZ { pub fn rotate_point3(&self, _point: Point3) -> Point3 { fail!("Not yet implemented.") } - pub fn rotate_vec3(&self, _vec: Vec3) -> Point3 { + pub fn rotate_vec3(&self, _vec: &Vec3) -> Vec3 { fail!("Not yet implemented.") } - pub fn rotate_ray3(&self, _vec: Ray3) -> Ray3 { + pub fn rotate_ray3(&self, _ray: &Ray3) -> Ray3 { fail!("Not yet implemented.") }