def compute_size(width, height, rotate)
width = width.to_f
height = height.to_f
radius = 0
unless rotate.zero?
radius = rotate / 180.0 * Math::PI
if (90 < rotate and rotate < 180) or
(270 < rotate and rotate < 360)
radius -= Math::PI / 2
end
end
inner_angle1 = Math.atan(width / height)
inner_angle2 = Math.atan(height / width)
diagonal = Math.sqrt(width ** 2 + height ** 2)
angle1 = radius + inner_angle1
angle2 = radius + inner_angle2
bottom1 = diagonal * Math.cos(angle1)
length1 = (bottom1 * Math.tan(angle1)).abs.to_i
bottom2 = diagonal * Math.cos(angle2)
length2 = (bottom2 * Math.tan(angle2)).abs.to_i
if (0 <= rotate and rotate <= 90) or
(180 <= rotate and rotate <= 270)
[length1, length2]
else
[length2, length1]
end
end