require "matrix" sx,sy = 2.0, 3.0; unit = 2 scale = Matrix[[sx,0], [0, sy]] scale*unit # => [2.0, 3.0]: scaled point theta = Math::PI/2 # 90 degrees rotate = Matrix[[Math.cos(theta), -Math.sin(theta)], [Math.sin(theta), Math.cos(theta)]] rotate*unit # [-1.0, 1.0]: 90 degree rotation scale * (rotate*unit) # [-2.0, 3.0]