lib/ray_tracer/matrix.rb
def translation(x, y, z)
        matrix =
        [
          [1, 0, 0, x],
          [0, 1, 0, y],
          [0, 0, 1, z],
          [0, 0, 0, 1]
        ]
        build(4, 4) { |i, j| Rational(matrix.dig(i, j)) }
      end
# Build a translation matrix by first building an identity matrix
# then composing (adding) the translation vector to the last column
Build a translation matrix by first building an identity matrix
then composing (adding) the translation vector to the last column
Build a translation matrix by first building an identity matrix then composing ( adding ) the translation vector to the last column
def translation(x, y, z)
        matrix =
        [
          [1, 0, 0, x],
          [0, 1, 0, y],
          [0, 0, 1, z],
          [0, 0, 0, 1]
        ]
        build(4, 4) { |i, j| Rational(matrix.dig(i, j)) }
      end
def translation ( x , y , z ) matrix = [ [ 1 , 0 , 0 , x ] , [ 0 , 1 , 0 , y ] , [ 0 , 0 , 1 , z ] , [ 0 , 0 , 0 , 1 ] ] build ( 4 , 4 ) { | i , j | Rational ( matrix . dig ( i , j ) ) } end
Build a translation matrix by first building an identity matrix
then composing (adding) the translation vector to the last column
Build a translation matrix by first building an identity matrix then composing ( adding ) the translation vector to the last column
x
y
z