Fix strokeBounds calculation when a rotation matrix is in use.

The bounding box of the rotated pen ellipse was calculated wrongly.
This commit is contained in:
Jürg Lehni 2011-12-19 13:47:30 +01:00
parent daa1343155
commit 3ccb4a6ebe

View file

@ -1889,12 +1889,13 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
// dy/dt = b cos(t) cos(phi) - a sin(t) sin(phi) = 0
// this can be simplified to:
// tan(t) = -b * tan(phi) / a // x
// tan(t) = b * cot(phi) / a // y
// tan(t) = b * cot(phi) / a // y
// Solving for t gives:
// t = pi * n - arctan(b tan(phi)) // x
// t = pi * n + arctan(b cot(phi)) // y
var tx = - Math.atan(b * Math.tan(phi)),
ty = + Math.atan(b / Math.tan(phi)),
// t = pi * n - arctan(b * tan(phi) / a) // x
// t = pi * n + arctan(b * cot(phi) / a)
// = pi * n + arctan(b / tan(phi) / a) // y
var tx = -Math.atan(b * Math.tan(phi) / a),
ty = Math.atan(b / (Math.tan(phi) * a)),
// Due to symetry, we don't need to cycle through pi * n solutions:
x = a * Math.cos(tx) * Math.cos(phi)
- b * Math.sin(tx) * Math.sin(phi),