Square of the distance with other

May be used as an approximation to compare distance between two points.

var p0 = new Point[Float](0.0, 0.0)
var p1 = new Point[Float](2.0, 3.0)
assert p0.dist2(p1) == 13.0

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.dist2(p3).is_approx(29.0, 0.01)
assert p2.dist2(p4).is_approx(13.0, 0.01)
assert p4.dist2(p2).is_approx(13.0, 0.01)

Property definitions

geometry $ IPoint :: dist2
	# Square of the distance with `other`
	#
	# May be used as an approximation to compare distance between two points.
	#
	# ~~~
	# var p0 = new Point[Float](0.0, 0.0)
	# var p1 = new Point[Float](2.0, 3.0)
	# assert p0.dist2(p1) == 13.0
	# ~~~
	#
	# 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.dist2(p3).is_approx(29.0, 0.01)
	# assert p2.dist2(p4).is_approx(13.0, 0.01)
	# assert p4.dist2(p2).is_approx(13.0, 0.01)
	# ~~~
	fun dist2(other: Point[Numeric]): N
	do return x.value_of(other.dist2_with_2d(self))
lib/geometry/points_and_lines.nit:56,2--78,48

geometry $ IPoint3d :: dist2
	redef fun dist2(other)
	do return x.value_of(other.dist2_with_3d(self))
lib/geometry/points_and_lines.nit:133,2--134,48