distance (计算直线距离)

distance(x1, y1, x2, y2)

计算两点之间直线距离

参数
  • x1 (float) – 点 1 的 x 坐标

  • y1 (float) – 点 1 的 y 坐标

  • x2 (float) – 点 2 的 x 坐标

  • y2 (float) – 点 2 的 y 坐标

返回

两点之间的直线距离,单位米

返回类型

float

../_images/distance.png

实际案例

>>> import opt
>>> print(opt.distance(0, 0, 0, 1))
1.0