s/translate/translation/g to match book.
This commit is contained in:
parent
87bf924094
commit
6e73bab37f
@ -24,7 +24,7 @@ fn main() -> Result<()> {
|
||||
let w = 200;
|
||||
let h = w;
|
||||
let mut c = Canvas::new(w, h);
|
||||
let t = Matrix4x4::translate(0., 0.4, 0.);
|
||||
let t = Matrix4x4::translation(0., 0.4, 0.);
|
||||
let p = Tuple::point(0., 0., 0.);
|
||||
let rot_hour = Matrix4x4::rotation_z(-PI / 6.);
|
||||
|
||||
@ -35,7 +35,7 @@ fn main() -> Result<()> {
|
||||
// To convert to screen space, we translate by 0.5, scale to canvas size,
|
||||
// and invert the Y-axis.
|
||||
let world_to_screen =
|
||||
Matrix4x4::scaling(w as f32, -h as f32, 1.0) * Matrix4x4::translate(0.5, -0.5, 0.);
|
||||
Matrix4x4::scaling(w as f32, -h as f32, 1.0) * Matrix4x4::translation(0.5, -0.5, 0.);
|
||||
for _ in 0..12 {
|
||||
let canvas_pixel = world_to_screen * p;
|
||||
draw_dot(&mut c, canvas_pixel.x as usize, canvas_pixel.y as usize);
|
||||
|
||||
@ -175,7 +175,7 @@ impl PartialEq for Matrix3x3 {
|
||||
/// let p = Tuple::point(1., 0., 1.);
|
||||
/// let a = Matrix4x4::rotation_x(PI / 2.);
|
||||
/// let b = Matrix4x4::scaling(5., 5., 5.);
|
||||
/// let c = Matrix4x4::translate(10., 5., 7.);
|
||||
/// let c = Matrix4x4::translation(10., 5., 7.);
|
||||
/// // Apply rotation first.
|
||||
/// let p2 = a * p;
|
||||
/// assert_eq!(p2, Tuple::point(1., -1., 0.));
|
||||
@ -190,7 +190,7 @@ impl PartialEq for Matrix3x3 {
|
||||
/// let p = Tuple::point(1., 0., 1.);
|
||||
/// let a = Matrix4x4::rotation_x(PI / 2.);
|
||||
/// let b = Matrix4x4::scaling(5., 5., 5.);
|
||||
/// let c = Matrix4x4::translate(10., 5., 7.);
|
||||
/// let c = Matrix4x4::translation(10., 5., 7.);
|
||||
/// let t = c * b * a;
|
||||
/// assert_eq!(t * p, Tuple::point(15., 0., 7.));
|
||||
/// ```
|
||||
@ -251,7 +251,7 @@ impl Matrix4x4 {
|
||||
/// ```
|
||||
/// use rtchallenge::{matrices::Matrix4x4, tuples::Tuple};
|
||||
///
|
||||
/// let transform = Matrix4x4::translate(5., -3., 2.);
|
||||
/// let transform = Matrix4x4::translation(5., -3., 2.);
|
||||
/// let p = Tuple::point(-3., 4., 5.);
|
||||
/// assert_eq!(transform * p, Tuple::point(2., 1., 7.));
|
||||
///
|
||||
@ -261,7 +261,7 @@ impl Matrix4x4 {
|
||||
/// let v = Tuple::vector(-3., 4., 5.);
|
||||
/// assert_eq!(transform * v, v);
|
||||
/// ```
|
||||
pub fn translate(x: f32, y: f32, z: f32) -> Matrix4x4 {
|
||||
pub fn translation(x: f32, y: f32, z: f32) -> Matrix4x4 {
|
||||
Matrix4x4::new(
|
||||
[1., 0., 0., x],
|
||||
[0., 1., 0., y],
|
||||
|
||||
@ -50,7 +50,7 @@ impl Ray {
|
||||
///
|
||||
/// // Translating a ray
|
||||
/// let r = Ray::new(Tuple::point(1., 2., 3.), Tuple::vector(0., 1., 0.));
|
||||
/// let m = Matrix4x4::translate(3., 4., 5.);
|
||||
/// let m = Matrix4x4::translation(3., 4., 5.);
|
||||
/// let r2 = r.transform(m);
|
||||
/// assert_eq!(r2.origin, Tuple::point(4., 6., 8.));
|
||||
/// assert_eq!(r2.direction, Tuple::vector(0., 1., 0.));
|
||||
|
||||
@ -22,7 +22,7 @@ impl Default for Sphere {
|
||||
///
|
||||
/// // It can be changed by directly setting the transform member.
|
||||
/// let mut s = Sphere::default();
|
||||
/// let t = Matrix4x4::translate(2., 3., 4.);
|
||||
/// let t = Matrix4x4::translation(2., 3., 4.);
|
||||
/// s.transform = t.clone();
|
||||
/// assert_eq!(s.transform, t);
|
||||
/// ```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user