skspatial.objects.Vector.scalar_projection

Vector.scalar_projection(other: Union[ndarray, Sequence]) float64[source]

Return the scalar projection of an other vector onto the vector.

Parameters
otherarray_like

Other vector.

Returns
np.float64

Scalar projection.

Examples

>>> from skspatial.objects import Vector
>>> Vector([0, 1]).scalar_projection([2, 1])
1.0
>>> Vector([-1, -1]).scalar_projection([1, 0]).round(3)
-0.707
>>> Vector([0, 100]).scalar_projection([9, 5])
5.0
>>> Vector([5, 0]).scalar_projection([-10, 3])
-10.0