Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the width and height of rotated object after transform

This question is a followup to the question: width/height after transform.

I am posting a new question because that question only solves the width and not the height. The formula:

var x = $('#box').width()*Math.cos(rotationAngle) 
      + $('#box').height()*Math.sin(rotationAngle);

works well for the width, what is the equivalent formula to calculate the height?

Thanks.

like image 824
Light Avatar asked Jun 09 '13 10:06

Light


1 Answers

This is the best working formula I have come up with:

var h = $(obj).height() * Math.abs(Math.cos(deg)) + $(obj).width() * Math.abs(Math.sin(deg));
var w = $(obj).width() * Math.abs(Math.cos(deg)) + $(obj).height() * Math.abs(Math.sin(deg));
like image 125
Light Avatar answered Oct 24 '22 02:10

Light