[go: up one dir, main page]

Skip to content

Instantly share code, notes, and snippets.

@DennisGuo
Created December 7, 2016 03:32
Show Gist options
  • Save DennisGuo/5ab7c97cb4cccdcc1e79f67fd4d3b34c to your computer and use it in GitHub Desktop.
Save DennisGuo/5ab7c97cb4cccdcc1e79f67fd4d3b34c to your computer and use it in GitHub Desktop.
function getRandom(pre, next) {
return pre + (Math.random() * (next - pre)) * 0.01;
}
var num = 200,arr = [] , x = getRandom(113.953640, 116.953640),y = getRandom(22.537018, 25.537018);
arr.push({x:x,y:y});
//阿基米德螺旋
var a =1,b =0.1,fix = 0.001;
for(var i=0;i<num;i++){
var angle = 0.1 * i;
var _x = x + (a + b * angle) * Math.cos(angle) * fix;
var _y = y + (a + b * angle) * Math.sin(angle) * fix;
arr.push({x:_x,y:_y });
}
console.log(JSON.stringify(arr));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment