on master help sign in
Make vector rotation more efficient in `insideForm`.
0a1461devancz
core-js/Graphics/Collage.js+4−6
@@ -278,12 +278,10 @@ function insideShape(point,theta,scale,pos,points) {
278 var x = (point[1] - pos[1]) / scale;
278 var x = (point[1] - pos[1]) / scale;
279 var y = (point[2] - pos[2]) / scale;
279 var y = (point[2] - pos[2]) / scale;
280 if (theta !== 0) {
280 if (theta !== 0) {
281− var angle = 2 * Math.PI * theta;
281+ var t = 2 * Math.PI * theta;
282− var t = x === 0 ? (y > 0 ? Math.PI/2 : -Math.PI/2) - angle
282+ var nx = x * Math.cos(t) - y * Math.sin(t);
283− : (Math.atan(y/x) + (x > 0 ? 0 : Math.PI)) - angle;
284− var r = Math.sqrt(x*x + y*y);
285− x = r * Math.cos(t);
283+ y = x * Math.sin(t) + y * Math.cos(t);
286− y = r * Math.sin(t);
284+ x = nx;
287 }
285 }
288
286
289 if (points.length === 0) { return false; }
287 if (points.length === 0) { return false; }