pub trait Projective3D<T>{
Show 15 methods
// Required method
fn transform(&self, m: &[&T; 16]) -> Self;
// Provided methods
fn rotate(&self, _alpha: T, _beta: T, _gamma: T) -> Self { ... }
fn rotate_point(
&self,
_point: &[T; 3],
_alpha: T,
_beta: T,
_gamma: T,
) -> Self { ... }
fn rotate_axis(&self, _p1: &[T; 3], _p2: &[T; 3], _alpha: T) -> Self { ... }
fn rotate_axis_x(&self, alpha: T) -> Self { ... }
fn rotate_axis_y(&self, alpha: T) -> Self { ... }
fn rotate_axis_z(&self, alpha: T) -> Self { ... }
fn translate(&self, x: &T, y: &T, z: &T) -> Self { ... }
fn translate_x(&self, x: &T) -> Self { ... }
fn translate_y(&self, y: &T) -> Self { ... }
fn translate_z(&self, y: &T) -> Self { ... }
fn scale(&self, x: &T, y: &T, z: &T) -> Self { ... }
fn scale_x(self, x: &T) -> Self { ... }
fn scale_y(self, y: &T) -> Self { ... }
fn scale_z(self, z: &T) -> Self { ... }
}Expand description
3D projective transformations
§Examples
use projective::Projective3D;
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Point(f64, f64, f64);
#[rustfmt::skip]
impl Projective3D<f64> for Point {
fn transform(&self, matrix: &[&f64; 16]) -> Self {
Point(
matrix[0] * self.0 + matrix[1] * self.1 + matrix[2] * self.2 + matrix[3],
matrix[4] * self.0 + matrix[5] * self.1 + matrix[6] * self.2 + matrix[7],
matrix[8] * self.0 + matrix[9] * self.1 + matrix[10] * self.2 + matrix[11],
)
}
}
#[test]
fn test_transform() {
let p0 = Point(1.0, 2.0, 3.0);
assert_eq!(p0.translate(&3.0, &2.0, &1.0), Point(4.0, 4.0, 4.0));
assert_eq!(p0.scale(&1.0, &2.0, &3.0), Point(1.0, 4.0, 9.0));
}Required Methods§
Provided Methods§
Sourcefn rotate_point(&self, _point: &[T; 3], _alpha: T, _beta: T, _gamma: T) -> Self
fn rotate_point(&self, _point: &[T; 3], _alpha: T, _beta: T, _gamma: T) -> Self
Transform by a 3×3 matrix.
Sourcefn rotate_axis(&self, _p1: &[T; 3], _p2: &[T; 3], _alpha: T) -> Self
fn rotate_axis(&self, _p1: &[T; 3], _p2: &[T; 3], _alpha: T) -> Self
Rotate with a line.
Sourcefn rotate_axis_x(&self, alpha: T) -> Self
fn rotate_axis_x(&self, alpha: T) -> Self
Rotate with a line.
Sourcefn rotate_axis_y(&self, alpha: T) -> Self
fn rotate_axis_y(&self, alpha: T) -> Self
Rotate with a line.
Sourcefn rotate_axis_z(&self, alpha: T) -> Self
fn rotate_axis_z(&self, alpha: T) -> Self
Rotate with a line.
Sourcefn translate_x(&self, x: &T) -> Self
fn translate_x(&self, x: &T) -> Self
Transform by length $\delta x$.
Sourcefn translate_y(&self, y: &T) -> Self
fn translate_y(&self, y: &T) -> Self
Transform by length $\delta y$.
Sourcefn translate_z(&self, y: &T) -> Self
fn translate_z(&self, y: &T) -> Self
Transform by length $\delta z$.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.