require "matrix" unit = 2 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