matrix in action : matrix « Number « Ruby






matrix in action


require "matrix"

# Represent the point (1,1) as the vector [1,1]
unit = Vector[1,1]

identity = Matrix.identity(2)  # 2x2 matrix
identity*unit == unit          # true: no transformation

 








Related examples in the same category

1.This matrix scales a point by sx,sy
2.This matrix rotates counterclockwise around the origin
3.Two transformations in one