I have a need to calculate the adjacent angle of a right angle triangle formed by a rectangle that is dictated by two sets of points. My plan is to use offset() on two elements to get absolute position co-ordinates, then determine the internal angle from the bottom left corner of this implied box so that i may rotate a thin rectangle element using css rotate.
Possible?
The only part i wouldn't know how to do right off the bat is the trigonometry syntax, and whether i need an external library for that.
*Note: I do understand that css rotate would rotate around the center of the element, so i would have to shift the rectangle over to compensate.
The answer lies not in jQuery, but in JavaScript. JavaScript has a Math object which contains sin, cos, tan and other trigonometry and math-related things.
For example, to calculate the sine of 45 degrees:
var degrees=45;
var radians=degrees*Math.PI/180;
var sine=Math.sin(radians);
alert("sin("+degrees+" deg) is roughly equal to "+sine);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With