答案 0 :(得分:2)
我们有N个部分和坐标差异
Dx = B.X - A.X
Dy = B.Y - A.Y
然后第i个分段结束的坐标是
P[i].X = A.X + i * Dx / N
P[i].Y = A.Y + i * Dy / N
答案 1 :(得分:1)
假设一行<body ng-class='{"is-loading": isLoading }'>
和A[x=0,y=0]
分为3个子行
B[x=9,y=9]
和A1[x=0,y=0]
B1[x=3,y=3]
和A2[x=3,y=3]
B2[x=6,y=6]
和A3[x=6,y=6]
您有两个班级:B3[x=9,y=9]
由2 line
s:
point
用法:
public class point
{
public double x { get; set; }
public double y { get; set; }
}
public class line
{
public point p1 { get; set; }
public point p2 { get; set; }
public line(point p1, point p2)
{
this.p1 = p1;
this.p2 = p2;
}
public List<line> SplitLine(int parts)
{
List<point> result = new List<point>();
for (int i = 0; i <= parts; i++)
{
result.Add(new point()
{
x = this.p1.x + (i * (this.p2.x - this.p1.x) / parts),
y = this.p1.y + (i * (this.p2.y - this.p1.y) / parts)
});
}
return Enumerable.Range(0, parts).Select(x => new line(result[x], result[x + 1])).ToList();
}
}