Merge pull request #893 from sapics/atan2

Replace atan to atan2 for avoiding NaN
This commit is contained in:
Jürg Lehni 2016-01-08 10:28:44 +01:00
commit 34a173ee18

View file

@ -2836,10 +2836,10 @@ statics: {
var sin = Math.sin(phi),
cos = Math.cos(phi),
tan = Math.tan(phi),
tx = -Math.atan(b * tan / a),
ty = Math.atan(b / (tan * a));
tx = Math.atan2(b * tan, a),
ty = Math.atan2(b, tan * a);
// Due to symetry, we don't need to cycle through pi * n solutions:
return [Math.abs(a * Math.cos(tx) * cos - b * Math.sin(tx) * sin),
return [Math.abs(a * Math.cos(tx) * cos + b * Math.sin(tx) * sin),
Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)];
},