other
var p0 = new Point[Float](0.0, 0.0)
var p1 = new Point[Float](2.0, 3.0)
assert p0.dist(p1).is_approx(3.6, 0.01)
If self
or other
are in 3D, the distance takes into account the 3 axes.
For a 2D point, the Z coordinate is considered to be 0.
var p2 = new Point3d[Float](0.0, 0.0, 0.0)
var p3 = new Point3d[Float](2.0, 3.0, 4.0)
var p4 = new Point[Float](2.0, 3.0)
assert p2.dist(p3).is_approx(5.385, 0.01)
assert p2.dist(p4).is_approx(3.606, 0.01)
# Distance with `other`
#
# ~~~
# var p0 = new Point[Float](0.0, 0.0)
# var p1 = new Point[Float](2.0, 3.0)
# assert p0.dist(p1).is_approx(3.6, 0.01)
# ~~~
#
# If `self` or `other` are in 3D, the distance takes into account the 3 axes.
# For a 2D point, the Z coordinate is considered to be 0.
#
# ~~~
# var p2 = new Point3d[Float](0.0, 0.0, 0.0)
# var p3 = new Point3d[Float](2.0, 3.0, 4.0)
# var p4 = new Point[Float](2.0, 3.0)
# assert p2.dist(p3).is_approx(5.385, 0.01)
# assert p2.dist(p4).is_approx(3.606, 0.01)
# ~~~
fun dist(other: Point[Numeric]): N
do
return x.value_of(dist2(other).to_f.sqrt)
end
lib/geometry/points_and_lines.nit:33,2--54,4