self
and other
at p
out of 1.0
var p0 = new Point[Float](0.0, 0.0)
var p1 = new Point[Float](2.0, 3.0)
assert p0.lerp(p1, 0.0) == p0
assert p0.lerp(p1, 1.0) == p1
assert p0.lerp(p1, 0.5) == new Point[Float](1.0, 1.5)
TODO 3D implementation.
# Linear interpolation between `self` and `other` at `p` out of `1.0`
#
# ~~~
# var p0 = new Point[Float](0.0, 0.0)
# var p1 = new Point[Float](2.0, 3.0)
# assert p0.lerp(p1, 0.0) == p0
# assert p0.lerp(p1, 1.0) == p1
# assert p0.lerp(p1, 0.5) == new Point[Float](1.0, 1.5)
# ~~~
#
# TODO 3D implementation.
fun lerp(other: Point[Numeric], p: Float): Point[N]
do
var xx = x.to_f + (other.x.to_f - x.to_f).to_f * p
var yy = y.to_f + (other.y.to_f - y.to_f).to_f * p
return new Point[N](x.value_of(xx), y.value_of(yy))
end
lib/geometry/points_and_lines.nit:95,2--111,4