function getLineDot(a, b){
var dot = [],
x1 = a.x,
x2 = b.x,
y1 = a.y,
y2 = b.y;
var r = Math.floor(Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
var theta = Math.atan((x2-x1)/(y2-y1));
if(((y2-y1)<0 && (x2-x1)>0)||((y2-y1)<0 && (x2-x1)<0))
theta = Math.PI+theta;
var dx = Math.sin(theta);
var dy = Math.cos(theta);
for(var i = 0; i < r;i++){
dot.push({x:x1+i*dx,y:y1+i*dy});
}
return dot;
}
两点间直线
最新推荐文章于 2022-01-25 09:56:26 发布