Math 如何进行线性插值?
我有一个线段,起点是sx1,y1,终点是ex2,y2。我用欧几里德距离计算了s和e之间的距离 d=sqrtx1-x2x1-x2+y1-y2y1-y2Math 如何进行线性插值?,math,distance,linear-interpolation,Math,Distance,Linear Interpolation,我有一个线段,起点是sx1,y1,终点是ex2,y2。我用欧几里德距离计算了s和e之间的距离 d=sqrtx1-x2x1-x2+y1-y2y1-y2 如何找出距离d10
如何找出距离d10
x(t)=x1+(x2-x1)*t;
y(t)=y1+(y2-y1)*t;
其中t是范围内的参数
如果t=0.0,则结果为x1点,y1点
如果t=1.0,则结果为x2,y2
所以,如果您需要距离起点d的点,则:
D=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
x(d)=x1+(x2-x1)*d/D;
y(d)=y1+(y2-y1)*d/D;
其中D是线长度
d是距离起点的距离
D=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
x(d)=x1+(x2-x1)*d/D;
y(d)=y1+(y2-y1)*d/D;