mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Replace atan to atan2 for avoiding NaN
This commit is contained in:
parent
3c66c013d1
commit
5f876adc1c
1 changed files with 3 additions and 3 deletions
|
@ -2836,10 +2836,10 @@ statics: {
|
||||||
var sin = Math.sin(phi),
|
var sin = Math.sin(phi),
|
||||||
cos = Math.cos(phi),
|
cos = Math.cos(phi),
|
||||||
tan = Math.tan(phi),
|
tan = Math.tan(phi),
|
||||||
tx = -Math.atan(b * tan / a),
|
tx = Math.atan2(b * tan, a),
|
||||||
ty = Math.atan(b / (tan * a));
|
ty = Math.atan2(b, tan * a);
|
||||||
// Due to symetry, we don't need to cycle through pi * n solutions:
|
// 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)];
|
Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue