mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Merge pull request #893 from sapics/atan2
Replace atan to atan2 for avoiding NaN
This commit is contained in:
commit
34a173ee18
1 changed files with 3 additions and 3 deletions
|
@ -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)];
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue